Skip to content

plasma_current

Plasma current scaling models and calculations.

This module provides various plasma current scaling models used in fusion physics calculations, including empirical and analytical fits based on different tokamak designs and experimental data.

PlasmaCurrent

Bases: Model

Class to hold plasma current calculations for plasma processing.

Source code in process/models/physics/plasma_current.py
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
class PlasmaCurrent(Model):
    """Class to hold plasma current calculations for plasma processing."""

    def __init__(self):
        """Initialize PlasmaCurrent with output file constants."""
        self.outfile = constants.NOUT
        self.mfile = constants.MFILE

    def run(self):
        """PlasmaCurrent model doesn't need to be run"""

    def output(self) -> None:
        """Output plasma current and safety factor information."""
        po.oheadr(self.outfile, "Plasma Current and Safety Factor")

        if self.data.stellarator.istell == StellaratorModel.DISABLED:
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "Plasma current scaling law used",
                "(i_plasma_current)",
                self.data.physics.i_plasma_current,
            )
            full_model_name = PlasmaCurrentModel(
                self.data.physics.i_plasma_current
            ).full_name
            po.ocmmnt(
                self.outfile,
                f"Plasma current model selected: {full_model_name} ",
            )

            po.ovarre(
                self.outfile,
                "Plasma current (Iₚ) (MA)",
                "(plasma_current_MA)",
                self.data.physics.plasma_current / 1.0e6,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Plasma current (Iₚ) (A)",
                "(plasma_current)",
                self.data.physics.plasma_current,
                "OP ",
            )

            self.output_plasma_current_models()
            po.oblnkl(self.outfile)

            if self.data.physics.i_alphaj == 1:
                po.ovarre(
                    self.outfile,
                    "Current density profile factor (αⱼ)",
                    "(alphaj)",
                    self.data.physics.alphaj,
                    "OP ",
                )
            else:
                po.ovarre(
                    self.outfile,
                    "Current density profile factor (αⱼ)",
                    "(alphaj)",
                    self.data.physics.alphaj,
                )
            po.ocmmnt(self.outfile, "Current profile index scalings:")
            po.oblnkl(self.outfile)

            po.ovarre(
                self.outfile,
                "J. Wesson plasma current profile index",
                "(alphaj_wesson)",
                self.data.physics.alphaj_wesson,
                "OP ",
            )
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "On-axis plasma current density (j₀) (A/m²)",
                "(j_plasma_on_axis)",
                self.data.physics.j_plasma_on_axis,
                "OP ",
            )

        if self.data.stellarator.istell == StellaratorModel.DISABLED:
            po.ovarre(
                self.outfile, "Safety factor on axis (q₀)", "(q0)", self.data.physics.q0
            )

            if self.data.physics.i_plasma_current == 2:
                po.ovarre(
                    self.outfile,
                    "Mean edge safety factor (q₉₅)",
                    "(q95)",
                    self.data.physics.q95,
                )

            po.ovarre(
                self.outfile,
                "Safety factor at 95% flux surface (q₉₅)",
                "(q95)",
                self.data.physics.q95,
            )

            po.ovarre(
                self.outfile,
                "Cylindrical safety factor (qcyl)",
                "(qstar)",
                self.data.physics.qstar,
                "OP ",
            )

            if (
                self.data.physics.i_plasma_geometry
                == PlasmaGeometryModelType.STAR_FIESTA
            ):
                po.ovarre(
                    self.outfile,
                    "Lower limit for edge safety factor q95",
                    "(q95_min)",
                    self.data.physics.q95_min,
                    "OP ",
                )
            po.oblnkl(self.outfile)

        else:
            po.ovarre(
                self.outfile,
                "Rotational transform",
                "(iotabar)",
                self.data.stellarator.iotabar,
            )

    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.

        Parameters
        ----------
        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 .
        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, float, float]
            Tuple containing (b_plasma_poloidal_average, qstar, plasma_current,
            betap, li).

        Raises
        ------
        ProcessValueError
            If invalid value for `i_plasma_current` is provided.
        ProcessValueError
            If triangularity is negative without `i_plasma_current = 8` selected.

        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
        ----------
        [1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
        unpublished internal Oak Ridge document

        [2] 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

        [3] ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
        ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

        [4] M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants
        - Part 1: Physics

        [5] H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO

        [6] 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

        [7] 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 (
            PlasmaCurrentModel(i_plasma_current) != PlasmaCurrentModel.SAUTER_SCALING
            and triang < 0.0
        ):
            raise ProcessValueError(
                f"Triangularity is negative without i_plasma_current = 8 selected:"
                f" {triang=}, {i_plasma_current=}"
            )

        try:  # noqa: PLW0717
            model = PlasmaCurrentModel(int(i_plasma_current))
            match model:
                # Calculate the function Fq that scales the edge q from the
                # circular cross-section cylindrical case

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

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

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

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

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

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

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

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

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

        except ValueError as e:
            raise ProcessValueError(
                "Illegal value of i_plasma_current",
                i_plasma_current=self.data.physics.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.
            Models which do not run successfully will map to a NaN.
        """
        results = {}
        for model in PlasmaCurrentModel:
            try:
                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,
                )
            except ProcessValueError:
                # Since this method is only used for output reporting, if a
                # Ip model cannot run (e.g. most models don't support negative triang)
                # then assign it NaN.
                results[model] = np.nan
        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=self.data.physics.alphaj,
            alphap=self.data.physics.alphap,
            b_plasma_toroidal_on_axis=self.data.physics.b_plasma_toroidal_on_axis,
            eps=self.data.physics.eps,
            kappa=self.data.physics.kappa,
            kappa95=self.data.physics.kappa95,
            pres_plasma_on_axis=self.data.physics.pres_plasma_thermal_on_axis,
            len_plasma_poloidal=self.data.physics.len_plasma_poloidal,
            q95=self.data.physics.q95,
            rmajor=self.data.physics.rmajor,
            rminor=self.data.physics.rminor,
            triang=self.data.physics.triang,
            triang95=self.data.physics.triang95,
        )

        self.data.physics.c_plasma_peng_analytic = plasma_currents.get(
            PlasmaCurrentModel.PENG_ANALYTIC_FIT
        )
        self.data.physics.c_plasma_peng_double_null = plasma_currents.get(
            PlasmaCurrentModel.PENG_DIVERTOR_SCALING
        )
        self.data.physics.c_plasma_cyclindrical = plasma_currents.get(
            PlasmaCurrentModel.ITER_SCALING
        )
        self.data.physics.c_plasma_ipdg89 = plasma_currents.get(
            PlasmaCurrentModel.IPDG89_SCALING
        )
        self.data.physics.c_plasma_todd_empirical_i = plasma_currents.get(
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I
        )
        self.data.physics.c_plasma_todd_empirical_ii = plasma_currents.get(
            PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II
        )
        self.data.physics.c_plasma_connor_hastie = plasma_currents.get(
            PlasmaCurrentModel.CONNOR_HASTIE_MODEL
        )
        self.data.physics.c_plasma_sauter = plasma_currents.get(
            PlasmaCurrentModel.SAUTER_SCALING
        )
        self.data.physics.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)",
            self.data.physics.c_plasma_peng_analytic,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}",
            "(c_plasma_peng_double_null)",
            self.data.physics.c_plasma_peng_double_null,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.ITER_SCALING.full_name}",
            "(c_plasma_cyclindrical)",
            self.data.physics.c_plasma_cyclindrical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}",
            "(c_plasma_ipdg89)",
            self.data.physics.c_plasma_ipdg89,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}",
            "(c_plasma_todd_empirical_i)",
            self.data.physics.c_plasma_todd_empirical_i,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}",
            "(c_plasma_todd_empirical_ii)",
            self.data.physics.c_plasma_todd_empirical_ii,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}",
            "(c_plasma_connor_hastie)",
            self.data.physics.c_plasma_connor_hastie,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}",
            "(c_plasma_sauter)",
            self.data.physics.c_plasma_sauter,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}",
            "(c_plasma_fiesta_st)",
            self.data.physics.c_plasma_fiesta_st,
            "OP ",
        )

    @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, triang: 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.
        triang :
            plasma triangularity.

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

        References
        ----------
        [1] 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

        [2] 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 + triang)) + triang
        c2 = (kappa**2 / (1.0 - triang)) - triang

        d1 = (kappa / (1.0 + triang)) ** 2 + 1.0
        d2 = (kappa / (1.0 - triang)) ** 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 + triang) / kappa)
        y2 = np.sqrt((c2 * eps + 1.0) / (1.0 - eps)) * ((1.0 - triang) / kappa)

        h2 = (1.0 + (c2 - 1.0) * (eps / 2.0)) / np.sqrt((1.0 - eps) * (c2 * eps + 1.0))
        f2 = (d2 * (1.0 - triang) * eps) / ((1.0 - eps) * ((c2 * eps) + 1.0))
        g = (eps * kappa) / (1.0 - (eps * triang))
        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 + triang) * 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

    @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.

        Parameters
        ----------
        eps:
            Plasma inverse aspect ratio [-].
        len_plasma_poloidal:
            Plasma poloidal perimeter length [m].
        rminor:
            Plasma minor radius [m].

        Returns
        -------
        :
            The plasma current scaling coefficient.

        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,
        rminor: float,
        b_plasma_toroidal_on_axis: float,
        kappa: float,
        triang: float,
    ) -> float:
        """
        Function to calculate plasma current (Peng scaling from the STAR code)

        Parameters
        ----------
        - q95:
            95% flux surface safety factor.
        - aspect:
            plasma aspect ratio.
        - rminor:
            plasma minor radius [m].
        - b_plasma_toroidal_on_axis:
            toroidal field on axis [T].
        - kappa:
            plasma elongation.
        - triang:
            plasma triangularity.

        Returns
        -------
        :
            plasma current [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
        ----------
        [1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
        unpublished internal Oak Ridge document

        [2] 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 by inverting q95 = 1.3 * qbar * (1 - eps)^0.6
        # (Muldrew et al., Fusion Eng. Des. 154 (2020) 111530, Eq. 19). Prior to
        # #3320 the input safety factor was interpreted as qbar directly and q95
        # was derived from it with the forward relation above.
        qbar = q95 / (1.3e0 * (1.0e0 - (1.0 / aspect)) ** 0.6e0)

        ff1, ff2, d1, d2 = self.plascar_bpol(
            aspect=aspect, eps=(1.0 / aspect), kappa=kappa, triang=triang
        )

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

        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

        References
        ----------
        [1] N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'

        [2] T.C.Hender et.al., 'Physics Assessment 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

        Raises
        ------
        ProcessValueError
            If model is not 1 or 2

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

        References
        ----------
        [1] D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181

        [2] T.C.Hender et.al., 'Physics Assessment 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,
        triang95: 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].
        triang95: 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) [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

        References
        ----------
        [1] 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

        [2] T.C.Hender et.al., 'Physics Assessment 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 * triang95 / 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

        References
        ----------
        [1] 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
        ----------
        [1] 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

run()

PlasmaCurrent model doesn't need to be run

Source code in process/models/physics/plasma_current.py
34
35
def run(self):
    """PlasmaCurrent model doesn't need to be run"""

output()

Output plasma current and safety factor information.

Source code in process/models/physics/plasma_current.py
 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
def output(self) -> None:
    """Output plasma current and safety factor information."""
    po.oheadr(self.outfile, "Plasma Current and Safety Factor")

    if self.data.stellarator.istell == StellaratorModel.DISABLED:
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Plasma current scaling law used",
            "(i_plasma_current)",
            self.data.physics.i_plasma_current,
        )
        full_model_name = PlasmaCurrentModel(
            self.data.physics.i_plasma_current
        ).full_name
        po.ocmmnt(
            self.outfile,
            f"Plasma current model selected: {full_model_name} ",
        )

        po.ovarre(
            self.outfile,
            "Plasma current (Iₚ) (MA)",
            "(plasma_current_MA)",
            self.data.physics.plasma_current / 1.0e6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Plasma current (Iₚ) (A)",
            "(plasma_current)",
            self.data.physics.plasma_current,
            "OP ",
        )

        self.output_plasma_current_models()
        po.oblnkl(self.outfile)

        if self.data.physics.i_alphaj == 1:
            po.ovarre(
                self.outfile,
                "Current density profile factor (αⱼ)",
                "(alphaj)",
                self.data.physics.alphaj,
                "OP ",
            )
        else:
            po.ovarre(
                self.outfile,
                "Current density profile factor (αⱼ)",
                "(alphaj)",
                self.data.physics.alphaj,
            )
        po.ocmmnt(self.outfile, "Current profile index scalings:")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "J. Wesson plasma current profile index",
            "(alphaj_wesson)",
            self.data.physics.alphaj_wesson,
            "OP ",
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "On-axis plasma current density (j₀) (A/m²)",
            "(j_plasma_on_axis)",
            self.data.physics.j_plasma_on_axis,
            "OP ",
        )

    if self.data.stellarator.istell == StellaratorModel.DISABLED:
        po.ovarre(
            self.outfile, "Safety factor on axis (q₀)", "(q0)", self.data.physics.q0
        )

        if self.data.physics.i_plasma_current == 2:
            po.ovarre(
                self.outfile,
                "Mean edge safety factor (q₉₅)",
                "(q95)",
                self.data.physics.q95,
            )

        po.ovarre(
            self.outfile,
            "Safety factor at 95% flux surface (q₉₅)",
            "(q95)",
            self.data.physics.q95,
        )

        po.ovarre(
            self.outfile,
            "Cylindrical safety factor (qcyl)",
            "(qstar)",
            self.data.physics.qstar,
            "OP ",
        )

        if (
            self.data.physics.i_plasma_geometry
            == PlasmaGeometryModelType.STAR_FIESTA
        ):
            po.ovarre(
                self.outfile,
                "Lower limit for edge safety factor q95",
                "(q95_min)",
                self.data.physics.q95_min,
                "OP ",
            )
        po.oblnkl(self.outfile)

    else:
        po.ovarre(
            self.outfile,
            "Rotational transform",
            "(iotabar)",
            self.data.stellarator.iotabar,
        )

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.

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
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

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
tuple[float, float, float, float, float]

Tuple containing (b_plasma_poloidal_average, qstar, plasma_current, betap, li).

Raises:

Type Description
ProcessValueError

If invalid value for i_plasma_current is provided.

ProcessValueError

If triangularity is negative without i_plasma_current = 8 selected.

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

[1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document

[2] 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

[3] ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

[4] M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants - Part 1: Physics

[5] H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO

[6] 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

[7] Sauter, Geometric formulas for systems codes..., FED 2016

Source code in process/models/physics/plasma_current.py
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
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.

    Parameters
    ----------
    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 .
    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, float, float]
        Tuple containing (b_plasma_poloidal_average, qstar, plasma_current,
        betap, li).

    Raises
    ------
    ProcessValueError
        If invalid value for `i_plasma_current` is provided.
    ProcessValueError
        If triangularity is negative without `i_plasma_current = 8` selected.

    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
    ----------
    [1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
    unpublished internal Oak Ridge document

    [2] 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

    [3] ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
    ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

    [4] M. Kovari et al, 2014, "PROCESS": A systems code for fusion power plants
    - Part 1: Physics

    [5] H. Zohm et al, 2013, On the Physics Guidelines for a Tokamak DEMO

    [6] 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

    [7] 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 (
        PlasmaCurrentModel(i_plasma_current) != PlasmaCurrentModel.SAUTER_SCALING
        and triang < 0.0
    ):
        raise ProcessValueError(
            f"Triangularity is negative without i_plasma_current = 8 selected:"
            f" {triang=}, {i_plasma_current=}"
        )

    try:  # noqa: PLW0717
        model = PlasmaCurrentModel(int(i_plasma_current))
        match model:
            # Calculate the function Fq that scales the edge q from the
            # circular cross-section cylindrical case

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

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

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

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

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

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

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

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

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

    except ValueError as e:
        raise ProcessValueError(
            "Illegal value of i_plasma_current",
            i_plasma_current=self.data.physics.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. Models which do not run successfully will map to a NaN.

Source code in process/models/physics/plasma_current.py
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
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.
        Models which do not run successfully will map to a NaN.
    """
    results = {}
    for model in PlasmaCurrentModel:
        try:
            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,
            )
        except ProcessValueError:
            # Since this method is only used for output reporting, if a
            # Ip model cannot run (e.g. most models don't support negative triang)
            # then assign it NaN.
            results[model] = np.nan
    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
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
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=self.data.physics.alphaj,
        alphap=self.data.physics.alphap,
        b_plasma_toroidal_on_axis=self.data.physics.b_plasma_toroidal_on_axis,
        eps=self.data.physics.eps,
        kappa=self.data.physics.kappa,
        kappa95=self.data.physics.kappa95,
        pres_plasma_on_axis=self.data.physics.pres_plasma_thermal_on_axis,
        len_plasma_poloidal=self.data.physics.len_plasma_poloidal,
        q95=self.data.physics.q95,
        rmajor=self.data.physics.rmajor,
        rminor=self.data.physics.rminor,
        triang=self.data.physics.triang,
        triang95=self.data.physics.triang95,
    )

    self.data.physics.c_plasma_peng_analytic = plasma_currents.get(
        PlasmaCurrentModel.PENG_ANALYTIC_FIT
    )
    self.data.physics.c_plasma_peng_double_null = plasma_currents.get(
        PlasmaCurrentModel.PENG_DIVERTOR_SCALING
    )
    self.data.physics.c_plasma_cyclindrical = plasma_currents.get(
        PlasmaCurrentModel.ITER_SCALING
    )
    self.data.physics.c_plasma_ipdg89 = plasma_currents.get(
        PlasmaCurrentModel.IPDG89_SCALING
    )
    self.data.physics.c_plasma_todd_empirical_i = plasma_currents.get(
        PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I
    )
    self.data.physics.c_plasma_todd_empirical_ii = plasma_currents.get(
        PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II
    )
    self.data.physics.c_plasma_connor_hastie = plasma_currents.get(
        PlasmaCurrentModel.CONNOR_HASTIE_MODEL
    )
    self.data.physics.c_plasma_sauter = plasma_currents.get(
        PlasmaCurrentModel.SAUTER_SCALING
    )
    self.data.physics.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)",
        self.data.physics.c_plasma_peng_analytic,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.PENG_DIVERTOR_SCALING.full_name}",
        "(c_plasma_peng_double_null)",
        self.data.physics.c_plasma_peng_double_null,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.ITER_SCALING.full_name}",
        "(c_plasma_cyclindrical)",
        self.data.physics.c_plasma_cyclindrical,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.IPDG89_SCALING.full_name}",
        "(c_plasma_ipdg89)",
        self.data.physics.c_plasma_ipdg89,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_I.full_name}",
        "(c_plasma_todd_empirical_i)",
        self.data.physics.c_plasma_todd_empirical_i,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.TODD_EMPIRICAL_SCALING_II.full_name}",
        "(c_plasma_todd_empirical_ii)",
        self.data.physics.c_plasma_todd_empirical_ii,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.CONNOR_HASTIE_MODEL.full_name}",
        "(c_plasma_connor_hastie)",
        self.data.physics.c_plasma_connor_hastie,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.SAUTER_SCALING.full_name}",
        "(c_plasma_sauter)",
        self.data.physics.c_plasma_sauter,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        f"{PlasmaCurrentModel.FIESTA_ST_SCALING.full_name}",
        "(c_plasma_fiesta_st)",
        self.data.physics.c_plasma_fiesta_st,
        "OP ",
    )

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
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
@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
    )

plascar_bpol(aspect, eps, kappa, triang) staticmethod

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:

Name Type Description Default
aspect float

plasma aspect ratio.

required
eps float

inverse aspect ratio.

required
kappa float

plasma elongation.

required
triang float

plasma triangularity.

required

Returns:

Type Description
tuple[float, float, float, float]

coefficients ff1, ff2, d1, d2

References

[1] 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

[2] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document

Source code in process/models/physics/plasma_current.py
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
@staticmethod
def plascar_bpol(
    aspect: float, eps: float, kappa: float, triang: 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.
    triang :
        plasma triangularity.

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

    References
    ----------
    [1] 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

    [2] 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 + triang)) + triang
    c2 = (kappa**2 / (1.0 - triang)) - triang

    d1 = (kappa / (1.0 + triang)) ** 2 + 1.0
    d2 = (kappa / (1.0 - triang)) ** 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 + triang) / kappa)
    y2 = np.sqrt((c2 * eps + 1.0) / (1.0 - eps)) * ((1.0 - triang) / kappa)

    h2 = (1.0 + (c2 - 1.0) * (eps / 2.0)) / np.sqrt((1.0 - eps) * (c2 * eps + 1.0))
    f2 = (d2 * (1.0 - triang) * eps) / ((1.0 - eps) * ((c2 * eps) + 1.0))
    g = (eps * kappa) / (1.0 - (eps * triang))
    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 + triang) * 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

calculate_current_coefficient_peng(eps, len_plasma_poloidal, rminor) staticmethod

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

Parameters:

Name Type Description Default
eps float

Plasma inverse aspect ratio [-].

required
len_plasma_poloidal float

Plasma poloidal perimeter length [m].

required
rminor float

Plasma minor radius [m].

required

Returns:

Type Description
float

The plasma current scaling coefficient.

References
None
Source code in process/models/physics/plasma_current.py
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
@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.

    Parameters
    ----------
    eps:
        Plasma inverse aspect ratio [-].
    len_plasma_poloidal:
        Plasma poloidal perimeter length [m].
    rminor:
        Plasma minor radius [m].

    Returns
    -------
    :
        The plasma current scaling coefficient.

    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, rminor, b_plasma_toroidal_on_axis, kappa, triang)

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

Returns:

Type Description
float

plasma current [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

[1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code, unpublished internal Oak Ridge document

[2] 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
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
def calculate_plasma_current_peng(
    self,
    q95: float,
    aspect: float,
    rminor: float,
    b_plasma_toroidal_on_axis: float,
    kappa: float,
    triang: float,
) -> float:
    """
    Function to calculate plasma current (Peng scaling from the STAR code)

    Parameters
    ----------
    - q95:
        95% flux surface safety factor.
    - aspect:
        plasma aspect ratio.
    - rminor:
        plasma minor radius [m].
    - b_plasma_toroidal_on_axis:
        toroidal field on axis [T].
    - kappa:
        plasma elongation.
    - triang:
        plasma triangularity.

    Returns
    -------
    :
        plasma current [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
    ----------
    [1] J D Galambos, STAR Code : Spherical Tokamak Analysis and Reactor Code,
    unpublished internal Oak Ridge document

    [2] 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 by inverting q95 = 1.3 * qbar * (1 - eps)^0.6
    # (Muldrew et al., Fusion Eng. Des. 154 (2020) 111530, Eq. 19). Prior to
    # #3320 the input safety factor was interpreted as qbar directly and q95
    # was derived from it with the forward relation above.
    qbar = q95 / (1.3e0 * (1.0e0 - (1.0 / aspect)) ** 0.6e0)

    ff1, ff2, d1, d2 = self.plascar_bpol(
        aspect=aspect, eps=(1.0 / aspect), kappa=kappa, triang=triang
    )

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

    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:

Name Type Description Default
eps float

plasma inverse aspect ratio.

required
kappa95 float

plasma elongation 95%.

required
triang95 float

plasma triangularity 95%.

required

Returns:

Type Description
float

the fq plasma current coefficient

References

[1] N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'

[2] T.C.Hender et.al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
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
@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

    References
    ----------
    [1] N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989'

    [2] T.C.Hender et.al., 'Physics Assessment 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:

Name Type Description Default
eps float

plasma inverse aspect ratio.

required
kappa95 float

plasma elongation 95%.

required
triang95 float

plasma triangularity 95%.

required

Returns:

Type Description
float

the fq plasma current coefficient

Raises:

Type Description
ProcessValueError

If model is not 1 or 2

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

[1] D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181

[2] T.C.Hender et.al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
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
@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

    Raises
    ------
    ProcessValueError
        If model is not 1 or 2

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

    References
    ----------
    [1] D.C.Robinson and T.N.Todd, Plasma and Contr Fusion 28 (1986) 1181

    [2] T.C.Hender et.al., 'Physics Assessment 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, triang95, 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:

Name Type Description Default
alphaj float
the current profile index [-].
required
alphap float
the pressure profile index [-].
required
b_plasma_toroidal_on_axis float
the toroidal field on axis [T].
required
triang95 float
the plasma triangularity 95% [-].
required
eps float
the inverse aspect ratio [-].
required
kappa95 float
the plasma elongation 95% [-].
required
pres_plasma_on_axis float
the central plasma pressure (Pa) [Pa].
required
rmu0 float
the vacuum permeability [H/m].
required

Returns:

Type Description
float

the F coefficient

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

[1] 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

[2] T.C.Hender et.al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992

Source code in process/models/physics/plasma_current.py
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
@staticmethod
def calculate_current_coefficient_hastie(
    alphaj: float,
    alphap: float,
    b_plasma_toroidal_on_axis: float,
    triang95: 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].
    triang95: 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) [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

    References
    ----------
    [1] 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

    [2] T.C.Hender et.al., 'Physics Assessment 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 * triang95 / 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:

Name Type Description Default
eps float
inverse aspect ratio [-].
required
kappa float
plasma elongation at the separatrix [-].
required
triang float
plasma triangularity at the separatrix [-].
required

Returns:

Type Description
float

the fq coefficient

References

[1] 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
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
@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

    References
    ----------
    [1] 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:

Name Type Description Default
eps float
plasma inverse aspect ratio.
required
kappa float
plasma elongation at the separatrix.
required
triang float
plasma triangularity at the separatrix.
required

Returns:

Type Description
float

the fq plasma current coefficient

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

[1] 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
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
@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
    ----------
    [1] 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

PlasmaDiamagneticCurrentModel

Bases: IntEnum

Enum for plasma diamagnetic current method types

Source code in process/models/physics/plasma_current.py
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
@unique
class PlasmaDiamagneticCurrentModel(IntEnum):
    """Enum for plasma diamagnetic current method types"""

    NONE = (0, "None")
    HENDER_ST_FIT = (1, "Hender ST fit")
    SCENE_FIT = (2, "SCENE fit")

    def __new__(cls, value: int, full_name: str):
        """Create a new enum member with value and full name.

        Parameters
        ----------
        value :
            The enum value
        full_name :
            The full name description of the enum member

        Returns
        -------
        PlasmaDiamagneticCurrentModel
            The new enum member
        """
        obj = int.__new__(cls, value)
        obj._value_ = value
        obj._full_name_ = full_name
        return obj

    @DynamicClassAttribute
    def full_name(self):
        """The full name of the enum member.

        Returns
        -------
        str
            The full name description
        """
        return self._full_name_

NONE = (0, 'None') class-attribute instance-attribute

HENDER_ST_FIT = (1, 'Hender ST fit') class-attribute instance-attribute

SCENE_FIT = (2, 'SCENE fit') class-attribute instance-attribute

full_name()

The full name of the enum member.

Returns:

Type Description
str

The full name description

Source code in process/models/physics/plasma_current.py
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
@DynamicClassAttribute
def full_name(self):
    """The full name of the enum member.

    Returns
    -------
    str
        The full name description
    """
    return self._full_name_

PlasmaDiamagneticCurrent

Bases: Model

Class to hold plasma diamagnetic current calculations for plasma processing.

Source code in process/models/physics/plasma_current.py
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
class PlasmaDiamagneticCurrent(Model):
    """Class to hold plasma diamagnetic current calculations for plasma processing."""

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

    def run(self):
        """Calculate plasma diamagnetic current fractions using scalings."""
        # Hender scaling for diamagnetic current at tight self.data.physics.aspect ratio
        self.data.current_drive.f_c_plasma_diamagnetic_hender = (
            self.diamagnetic_fraction_hender(self.data.physics.beta_total_vol_avg)
        )

        # SCENE scaling for diamagnetic current
        self.data.current_drive.f_c_plasma_diamagnetic_scene = (
            self.diamagnetic_fraction_scene(
                self.data.physics.beta_total_vol_avg,
                self.data.physics.q95,
                self.data.physics.q0,
            )
        )
        match PlasmaDiamagneticCurrentModel(self.data.physics.i_diamagnetic_current):
            case PlasmaDiamagneticCurrentModel.HENDER_ST_FIT:
                self.data.current_drive.f_c_plasma_diamagnetic = (
                    self.data.current_drive.f_c_plasma_diamagnetic_hender
                )
            case PlasmaDiamagneticCurrentModel.SCENE_FIT:
                self.data.current_drive.f_c_plasma_diamagnetic = (
                    self.data.current_drive.f_c_plasma_diamagnetic_scene
                )

    def output(self):
        """Output the plasma diamagnetic current model results."""
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Plasma diamagnetic current fraction scaling law used",
            "(i_diamagnetic_current)",
            self.data.physics.i_diamagnetic_current,
        )
        full_model_name = PlasmaDiamagneticCurrentModel(
            self.data.physics.i_diamagnetic_current
        ).full_name
        po.ocmmnt(
            self.outfile,
            f"Diamagnetic current fraction model selected: {full_model_name} ",
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Diamagnetic fraction (Hender)",
            "(f_c_plasma_diamagnetic_hender)",
            self.data.current_drive.f_c_plasma_diamagnetic_hender,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Diamagnetic fraction (SCENE)",
            "(f_c_plasma_diamagnetic_scene)",
            self.data.current_drive.f_c_plasma_diamagnetic_scene,
            "OP ",
        )
        po.oblnkl(self.outfile)
        if (
            self.data.physics.i_diamagnetic_current == PlasmaDiamagneticCurrentModel.NONE
            and self.data.current_drive.f_c_plasma_diamagnetic_scene > 0.01e0
        ):
            # Error to show if diamagnetic current is above 1% but not used
            logger.error(
                "Diamagnetic fraction is more than 1%, but not calculated. "
                "Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1"
            )

    @staticmethod
    @nb.njit(cache=True)
    def diamagnetic_fraction_hender(beta: float) -> float:
        """Calculate the diamagnetic fraction based on the Hender fit.

        Parameters
        ----------
        beta :
            the plasma beta value

        Returns
        -------
        float
            the diamagnetic fraction

        """
        return beta / 2.8

    @staticmethod
    @nb.njit(cache=True)
    def diamagnetic_fraction_scene(beta: float, q95: float, q0: float) -> float:
        """Calculate the diamagnetic fraction based on the SCENE fit by Tim Hender.

        Parameters
        ----------
        beta :
            the plasma beta value.
        q95 :
            the normalized safety factor at 95% of the plasma radius.
        q0 :
            the normalized safety factor at the magnetic axis.

        Returns
        -------
        :
            the diamagnetic fraction
        """
        return beta * (0.1 * q95 / q0 + 0.44) * 0.414

outfile = constants.NOUT instance-attribute

mfile = constants.MFILE instance-attribute

run()

Calculate plasma diamagnetic current fractions using scalings.

Source code in process/models/physics/plasma_current.py
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
def run(self):
    """Calculate plasma diamagnetic current fractions using scalings."""
    # Hender scaling for diamagnetic current at tight self.data.physics.aspect ratio
    self.data.current_drive.f_c_plasma_diamagnetic_hender = (
        self.diamagnetic_fraction_hender(self.data.physics.beta_total_vol_avg)
    )

    # SCENE scaling for diamagnetic current
    self.data.current_drive.f_c_plasma_diamagnetic_scene = (
        self.diamagnetic_fraction_scene(
            self.data.physics.beta_total_vol_avg,
            self.data.physics.q95,
            self.data.physics.q0,
        )
    )
    match PlasmaDiamagneticCurrentModel(self.data.physics.i_diamagnetic_current):
        case PlasmaDiamagneticCurrentModel.HENDER_ST_FIT:
            self.data.current_drive.f_c_plasma_diamagnetic = (
                self.data.current_drive.f_c_plasma_diamagnetic_hender
            )
        case PlasmaDiamagneticCurrentModel.SCENE_FIT:
            self.data.current_drive.f_c_plasma_diamagnetic = (
                self.data.current_drive.f_c_plasma_diamagnetic_scene
            )

output()

Output the plasma diamagnetic current model results.

Source code in process/models/physics/plasma_current.py
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
def output(self):
    """Output the plasma diamagnetic current model results."""
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Plasma diamagnetic current fraction scaling law used",
        "(i_diamagnetic_current)",
        self.data.physics.i_diamagnetic_current,
    )
    full_model_name = PlasmaDiamagneticCurrentModel(
        self.data.physics.i_diamagnetic_current
    ).full_name
    po.ocmmnt(
        self.outfile,
        f"Diamagnetic current fraction model selected: {full_model_name} ",
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Diamagnetic fraction (Hender)",
        "(f_c_plasma_diamagnetic_hender)",
        self.data.current_drive.f_c_plasma_diamagnetic_hender,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Diamagnetic fraction (SCENE)",
        "(f_c_plasma_diamagnetic_scene)",
        self.data.current_drive.f_c_plasma_diamagnetic_scene,
        "OP ",
    )
    po.oblnkl(self.outfile)
    if (
        self.data.physics.i_diamagnetic_current == PlasmaDiamagneticCurrentModel.NONE
        and self.data.current_drive.f_c_plasma_diamagnetic_scene > 0.01e0
    ):
        # Error to show if diamagnetic current is above 1% but not used
        logger.error(
            "Diamagnetic fraction is more than 1%, but not calculated. "
            "Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1"
        )

diamagnetic_fraction_hender(beta) staticmethod

Calculate the diamagnetic fraction based on the Hender fit.

Parameters:

Name Type Description Default
beta float

the plasma beta value

required

Returns:

Type Description
float

the diamagnetic fraction

Source code in process/models/physics/plasma_current.py
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
@staticmethod
@nb.njit(cache=True)
def diamagnetic_fraction_hender(beta: float) -> float:
    """Calculate the diamagnetic fraction based on the Hender fit.

    Parameters
    ----------
    beta :
        the plasma beta value

    Returns
    -------
    float
        the diamagnetic fraction

    """
    return beta / 2.8

diamagnetic_fraction_scene(beta, q95, q0) staticmethod

Calculate the diamagnetic fraction based on the SCENE fit by Tim Hender.

Parameters:

Name Type Description Default
beta float

the plasma beta value.

required
q95 float

the normalized safety factor at 95% of the plasma radius.

required
q0 float

the normalized safety factor at the magnetic axis.

required

Returns:

Type Description
float

the diamagnetic fraction

Source code in process/models/physics/plasma_current.py
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
@staticmethod
@nb.njit(cache=True)
def diamagnetic_fraction_scene(beta: float, q95: float, q0: float) -> float:
    """Calculate the diamagnetic fraction based on the SCENE fit by Tim Hender.

    Parameters
    ----------
    beta :
        the plasma beta value.
    q95 :
        the normalized safety factor at 95% of the plasma radius.
    q0 :
        the normalized safety factor at the magnetic axis.

    Returns
    -------
    :
        the diamagnetic fraction
    """
    return beta * (0.1 * q95 / q0 + 0.44) * 0.414