Skip to content

current_drive

NeutralBeam

Source code in process/models/physics/current_drive.py
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
class NeutralBeam:
    def __init__(self, plasma_profile: PlasmaProfile):
        self.outfile = constants.NOUT
        self.plasma_profile = plasma_profile

    def iternb(self):
        """Routine to calculate ITER Neutral Beam current drive parameters

        Returns
        -------
        effnbss:
            neutral beam current drive efficiency (A/W)
        f_p_beam_injected_ions:
            fraction of NB power given to ions
        fshine:
             shine-through fraction of beam

        Notes
        -----
        This routine calculates the current drive parameters for a
        neutral beam system, based on the 1990 ITER model.
        ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
        ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990
        """
        # Check argument sanity
        if (
            1 + physics_variables.eps
        ) < current_drive_variables.f_radius_beam_tangency_rmajor:
            raise ProcessValueError(
                "Imminent negative square root argument; NBI will miss plasma completely",
                eps=physics_variables.eps,
                f_radius_beam_tangency_rmajor=current_drive_variables.f_radius_beam_tangency_rmajor,
            )

        # Calculate beam path length to centre
        dpath = physics_variables.rmajor * np.sqrt(
            (1.0 + physics_variables.eps) ** 2
            - current_drive_variables.f_radius_beam_tangency_rmajor**2
        )

        # Calculate beam stopping cross-section
        sigstop = self.sigbeam(
            current_drive_variables.e_beam_kev / physics_variables.m_beam_amu,
            physics_variables.temp_plasma_electron_vol_avg_kev,
            physics_variables.nd_plasma_electrons_vol_avg,
            physics_variables.f_nd_alpha_electron,
            physics_variables.f_nd_plasma_carbon_electron,
            physics_variables.f_nd_plasma_oxygen_electron,
            physics_variables.f_nd_plasma_iron_argon_electron,
        )

        # Calculate number of decay lengths to centre
        current_drive_variables.n_beam_decay_lengths_core = (
            dpath * physics_variables.nd_plasma_electrons_vol_avg * sigstop
        )

        # Shine-through fraction of beam
        fshine = np.exp(
            -2.0 * dpath * physics_variables.nd_plasma_electrons_vol_avg * sigstop
        )
        fshine = max(fshine, 1e-20)

        # Deuterium and tritium beam densities
        dend = physics_variables.nd_plasma_fuel_ions_vol_avg * (
            1.0 - current_drive_variables.f_beam_tritium
        )
        dent = (
            physics_variables.nd_plasma_fuel_ions_vol_avg
            * current_drive_variables.f_beam_tritium
        )

        # Power split to ions / electrons
        f_p_beam_injected_ions = self.cfnbi(
            physics_variables.m_beam_amu,
            current_drive_variables.e_beam_kev,
            physics_variables.temp_plasma_electron_density_weighted_kev,
            physics_variables.nd_plasma_electrons_vol_avg,
            dend,
            dent,
            physics_variables.n_charge_plasma_effective_mass_weighted_vol_avg,
            physics_variables.dlamie,
        )

        # Current drive efficiency
        effnbss = current_drive_variables.f_radius_beam_tangency_rmajor * self.etanb(
            physics_variables.m_beam_amu,
            physics_variables.alphan,
            physics_variables.alphat,
            physics_variables.aspect,
            physics_variables.nd_plasma_electrons_vol_avg,
            current_drive_variables.e_beam_kev,
            physics_variables.rmajor,
            physics_variables.temp_plasma_electron_density_weighted_kev,
            physics_variables.n_charge_plasma_effective_vol_avg,
        )

        return effnbss, f_p_beam_injected_ions, fshine

    def culnbi(self):
        """Routine to calculate Neutral Beam current drive parameters

        Returns
        -------
        effnbss:
            neutral beam current drive efficiency (A/W)
        f_p_beam_injected_ions:
            fraction of NB power given to ions
        fshine:
            shine-through fraction of beam

        Notes
        -----
        This routine calculates Neutral Beam current drive parameters
        using the corrections outlined in AEA FUS 172 to the ITER method.
        <P>The result cannot be guaranteed for devices with aspect ratios far
        from that of ITER (approx. 2.8).
        AEA FUS 172: Physics Assessment for the European Reactor Study
        """
        if (
            1.0e0 + physics_variables.eps
        ) < current_drive_variables.f_radius_beam_tangency_rmajor:
            raise ProcessValueError(
                "Imminent negative square root argument; NBI will miss plasma completely",
                eps=physics_variables.eps,
                f_radius_beam_tangency_rmajor=current_drive_variables.f_radius_beam_tangency_rmajor,
            )

        #  Calculate beam path length to centre

        dpath = physics_variables.rmajor * np.sqrt(
            (1.0e0 + physics_variables.eps) ** 2
            - current_drive_variables.f_radius_beam_tangency_rmajor**2
        )

        #  Calculate beam stopping cross-section

        sigstop = self.sigbeam(
            current_drive_variables.e_beam_kev / physics_variables.m_beam_amu,
            physics_variables.temp_plasma_electron_vol_avg_kev,
            physics_variables.nd_plasma_electrons_vol_avg,
            physics_variables.f_nd_alpha_electron,
            physics_variables.f_nd_plasma_carbon_electron,
            physics_variables.f_nd_plasma_oxygen_electron,
            physics_variables.f_nd_plasma_iron_argon_electron,
        )

        #  Calculate number of decay lengths to centre

        current_drive_variables.n_beam_decay_lengths_core = (
            dpath * physics_variables.nd_plasma_electron_line * sigstop
        )

        #  Shine-through fraction of beam

        fshine = np.exp(
            -2.0e0 * dpath * physics_variables.nd_plasma_electron_line * sigstop
        )
        fshine = max(fshine, 1.0e-20)

        #  Deuterium and tritium beam densities

        dend = physics_variables.nd_plasma_fuel_ions_vol_avg * (
            1.0e0 - current_drive_variables.f_beam_tritium
        )
        dent = (
            physics_variables.nd_plasma_fuel_ions_vol_avg
            * current_drive_variables.f_beam_tritium
        )

        #  Power split to ions / electrons

        f_p_beam_injected_ions = self.cfnbi(
            physics_variables.m_beam_amu,
            current_drive_variables.e_beam_kev,
            physics_variables.temp_plasma_electron_density_weighted_kev,
            physics_variables.nd_plasma_electrons_vol_avg,
            dend,
            dent,
            physics_variables.n_charge_plasma_effective_mass_weighted_vol_avg,
            physics_variables.dlamie,
        )

        #  Current drive efficiency

        effnbss = self.etanb2(
            physics_variables.m_beam_amu,
            physics_variables.alphan,
            physics_variables.alphat,
            physics_variables.aspect,
            physics_variables.nd_plasma_electrons_vol_avg,
            physics_variables.nd_plasma_electron_line,
            current_drive_variables.e_beam_kev,
            current_drive_variables.f_radius_beam_tangency_rmajor,
            fshine,
            physics_variables.rmajor,
            physics_variables.rminor,
            physics_variables.temp_plasma_electron_density_weighted_kev,
            physics_variables.n_charge_plasma_effective_vol_avg,
        )

        return effnbss, f_p_beam_injected_ions, fshine

    def etanb2(
        self,
        m_beam_amu,
        alphan,
        alphat,
        aspect,
        nd_plasma_electrons_vol_avg,
        nd_plasma_electron_line,
        e_beam_kev,
        f_radius_beam_tangency_rmajor,
        fshine,
        rmajor,
        rminor,
        temp_plasma_electron_density_weighted_kev,
        zeff,
    ):
        """Routine to find neutral beam current drive efficiency
        using the ITER 1990 formulation, plus correction terms
        outlined in Culham Report AEA FUS 172


        This routine calculates the current drive efficiency in A/W of
        a neutral beam system, based on the 1990 ITER model,
        plus correction terms outlined in Culham Report AEA FUS 172.
        <P>The formulae are from AEA FUS 172, unless denoted by IPDG89.
        AEA FUS 172: Physics Assessment for the European Reactor Study
        ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
        ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

        Parameters
        ----------
        m_beam_amu:
            beam ion mass (amu)
        alphan:
            density profile factor
        alphat:
            temperature profile factor
        aspect:
            aspect ratio
        nd_plasma_electrons_vol_avg:
            volume averaged electron density (m**-3)
        nd_plasma_electron_line:
            line averaged electron density (m**-3)
        e_beam_kev:
            neutral beam energy (keV)
        f_radius_beam_tangency_rmajor:
            R_tangent / R_major for neutral beam injection
        fshine:
            shine-through fraction of beam
        rmajor:
            plasma major radius (m)
        rminor:
            plasma minor radius (m)
        temp_plasma_electron_density_weighted_kev:
            density weighted average electron temperature (keV)
        zeff:
            plasma effective charge
        """
        #  Charge of beam ions
        zbeam = 1.0

        #  Fitting factor (IPDG89)
        bbd = 1.0

        #  Volume averaged electron density (10**20 m**-3)
        dene20 = nd_plasma_electrons_vol_avg / 1e20

        #  Line averaged electron density (10**20 m**-3)
        dnla20 = nd_plasma_electron_line / 1e20

        #  Critical energy (MeV) (power to electrons = power to ions) (IPDG89)
        #  N.B. temp_plasma_electron_density_weighted_kev is in keV
        ecrit = 0.01 * m_beam_amu * temp_plasma_electron_density_weighted_kev

        #  Beam energy in MeV
        ebmev = e_beam_kev / 1e3

        #  x and y coefficients of function J0(x,y) (IPDG89)
        xjs = ebmev / (bbd * ecrit)
        xj = np.sqrt(xjs)

        yj = 0.8 * zeff / m_beam_amu

        #  Fitting function J0(x,y)
        j0 = xjs / (4.0 + 3.0 * yj + xjs * (xj + 1.39 + 0.61 * yj**0.7))

        #  Effective inverse aspect ratio, with a limit on its maximum value
        epseff = min(0.2, (0.5 / aspect))

        #  Reduction in the reverse electron current
        #  due to neoclassical effects
        gfac = (1.55 + 0.85 / zeff) * np.sqrt(epseff) - (0.2 + 1.55 / zeff) * epseff

        # Reduction in the net beam driven current
        #  due to the reverse electron current
        ffac = 1.0 - (zbeam / zeff) * (1.0 - gfac)

        #  Normalisation to allow results to be valid for
        #  non-ITER plasma size and density:
        #  Line averaged electron density (10**20 m**-3) normalised to ITER
        nnorm = 1.0

        #  Distance along beam to plasma centre
        r = max(rmajor, rmajor * f_radius_beam_tangency_rmajor)
        eps1 = rminor / r

        if (1.0 + eps1) < f_radius_beam_tangency_rmajor:
            raise ProcessValueError(
                "Imminent negative square root argument; NBI will miss plasma completely",
                eps=eps1,
                f_radius_beam_tangency_rmajor=f_radius_beam_tangency_rmajor,
            )

        d = rmajor * np.sqrt((1.0 + eps1) ** 2 - f_radius_beam_tangency_rmajor**2)

        # Distance along beam to plasma centre for ITER
        # assuming a tangency radius equal to the major radius
        epsitr = 2.15 / 6.0
        dnorm = 6.0 * np.sqrt(2.0 * epsitr + epsitr**2)

        #  Normalisation to beam energy (assumes a simplified formula for
        #  the beam stopping cross-section)
        ebnorm = ebmev * ((nnorm * dnorm) / (dnla20 * d)) ** (1.0 / 0.78)

        #  A_bd fitting coefficient, after normalisation with ebnorm
        abd = (
            0.107
            * (1.0 - 0.35 * alphan + 0.14 * alphan**2)
            * (1.0 - 0.21 * alphat)
            * (1.0 - 0.2 * ebnorm + 0.09 * ebnorm**2)
        )

        #  Normalised current drive efficiency (A/W m**-2) (IPDG89)
        gamnb = (
            5.0
            * abd
            * 0.1
            * temp_plasma_electron_density_weighted_kev
            * (1.0 - fshine)
            * f_radius_beam_tangency_rmajor
            * j0
            / 0.2
            * ffac
        )

        #  Current drive efficiency (A/W)
        return gamnb / (dene20 * rmajor)

    def etanb(
        self,
        m_beam_amu,
        alphan,
        alphat,
        aspect,
        nd_plasma_electrons_vol_avg,
        ebeam,
        rmajor,
        temp_plasma_electron_density_weighted_kev,
        zeff,
    ):
        """Routine to find neutral beam current drive efficiency
        using the ITER 1990 formulation

        Parameters
        ----------
        m_beam_amu:
            beam ion mass (amu)
        alphan:
            density profile factor
        alphat:
            temperature profile factor
        aspect:
            aspect ratio
        nd_plasma_electrons_vol_avg:
            volume averaged electron density (m**-3)
        ebeam:
            neutral beam energy (keV)
        rmajor:
            plasma major radius (m)
        temp_plasma_electron_density_weighted_kev:
            density weighted average electron temp. (keV)
        zeff:
            plasma effective charge

        Notes
        -----
        This routine calculates the current drive efficiency of
        a neutral beam system, based on the 1990 ITER model.
        ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
        ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990



        """

        zbeam = 1.0
        bbd = 1.0

        dene20 = 1e-20 * nd_plasma_electrons_vol_avg

        # Ratio of E_beam/E_crit
        xjs = ebeam / (
            bbd * 10.0 * m_beam_amu * temp_plasma_electron_density_weighted_kev
        )
        xj = np.sqrt(xjs)

        yj = 0.8 * zeff / m_beam_amu

        rjfunc = xjs / (4.0 + 3.0 * yj + xjs * (xj + 1.39 + 0.61 * yj**0.7))

        epseff = 0.5 / aspect
        gfac = (1.55 + 0.85 / zeff) * np.sqrt(epseff) - (0.2 + 1.55 / zeff) * epseff
        ffac = 1.0 / zbeam - (1.0 - gfac) / zeff

        abd = (
            0.107
            * (1.0 - 0.35 * alphan + 0.14 * alphan**2)
            * (1.0 - 0.21 * alphat)
            * (1.0 - 0.2e-3 * ebeam + 0.09e-6 * ebeam**2)
        )

        return (
            abd
            * (5.0 / rmajor)
            * (0.1 * temp_plasma_electron_density_weighted_kev / dene20)
            * rjfunc
            / 0.2
            * ffac
        )

    def sigbeam(self, eb, te, ne, rnhe, rnc, rno, rnfe):
        """Calculates the stopping cross-section for a hydrogen
               beam in a fusion plasma

        Parameters
        ----------
        eb:
            beam energy (kev/amu)
        te:
            electron temperature (keV)
        ne:
            electron density (10^20m-3)
        rnhe:
            alpha density / ne
        rnc:
            carbon density /ne
        rno:
            oxygen density /ne
        rnfe:
            iron density /ne

        Notes
        -----
        This function calculates the stopping cross-section (m^-2)
        for a hydrogen beam in a fusion plasma.
        Janev, Boley and Post, Nuclear Fusion 29 (1989) 2125
        """
        a = np.array([
            [
                [4.4, -2.49e-2],
                [7.46e-2, 2.27e-3],
                [3.16e-3, -2.78e-5],
            ],
            [
                [2.3e-1, -1.15e-2],
                [-2.55e-3, -6.2e-4],
                [1.32e-3, 3.38e-5],
            ],
        ])

        b = np.array([
            [
                [[-2.36, -1.49, -1.41, -1.03], [0.185, -0.0154, -4.08e-4, 0.106]],
                [
                    [-0.25, -0.119, -0.108, -0.0558],
                    [-0.0381, -0.015, -0.0138, -3.72e-3],
                ],
            ],
            [
                [
                    [0.849, 0.518, 0.477, 0.322],
                    [-0.0478, 7.18e-3, 1.57e-3, -0.0375],
                ],
                [
                    [0.0677, 0.0292, 0.0259, 0.0124],
                    [0.0105, 3.66e-3, 3.33e-3, 8.61e-4],
                ],
            ],
            [
                [
                    [-0.0588, -0.0336, -0.0305, -0.0187],
                    [4.34e-3, 3.41e-4, 7.35e-4, 3.53e-3],
                ],
                [
                    [-4.48e-3, -1.79e-3, -1.57e-3, -7.43e-4],
                    [-6.76e-4, -2.04e-4, -1.86e-4, -5.12e-5],
                ],
            ],
        ])

        z = np.array([2.0, 6.0, 8.0, 26.0])
        nn = np.array([rnhe, rnc, rno, rnfe])

        nen = ne * 1e-19

        s1 = 0.0
        for k in range(2):
            for j in range(3):
                for i in range(2):
                    s1 += (
                        a[i, j, k]
                        * (np.log(eb)) ** i
                        * (np.log(nen)) ** j
                        * (np.log(te)) ** k
                    )

        sz = 0.0
        for l in range(4):  # noqa: E741
            for k in range(2):
                for j in range(2):
                    for i in range(3):
                        sz += (
                            b[i, j, k, l]
                            * (np.log(eb)) ** i
                            * (np.log(nen)) ** j
                            * (np.log(te)) ** k
                            * nn[l]
                            * z[l]
                            * (z[l] - 1.0)
                        )

        return max(1e-20 * (np.exp(s1) / eb * (1.0 + sz)), 1e-23)

    def cfnbi(
        self,
        afast,
        efast,
        te,
        ne,
        _nd,
        _nt,
        n_charge_plasma_effective_mass_weighted_vol_avg,
        xlmbda,
    ):
        """Routine to calculate the fraction of the fast particle energy
         coupled to the ions

        Parameters
        ----------
        afast:
            mass of fast particle (units of proton mass)
        efast:
            energy of fast particle (keV)
        te:
            density weighted average electron temp. (keV)
        ne:
            volume averaged electron density (m**-3)
        nd:
            deuterium beam density (m**-3)
        nt:
            tritium beam density (m**-3)
        n_charge_plasma_effective_mass_weighted_vol_avg:
            mass weighted plasma effective charge
        xlmbda:
            ion-electron coulomb logarithm

        Returns
        -------
        f_p_beam_injected_ions:
             fraction of fast particle energy coupled to ions
        Notes
        -----
        This routine calculates the fast particle energy coupled to
        the ions in the neutral beam system.
        """
        # atmd = 2.0
        atmdt = 2.5
        # atmt = 3.0
        c = 3.0e8
        me = constants.ELECTRON_MASS
        # zd = 1.0
        # zt = 1.0

        # xlbd = self.xlmbdabi(afast, atmd, efast, te, ne)
        # xlbt = self.xlmbdabi(afast, atmt, efast, te, ne)

        # sum = nd * zd * zd * xlbd / atmd + nt * zt * zt * xlbt / atmt
        # ecritfix = 16.0e0 * te * afast * (sum / (ne * xlmbda)) ** (2.0e0 / 3.0e0)

        xlmbdai = self.xlmbdabi(afast, atmdt, efast, te, ne)
        sumln = n_charge_plasma_effective_mass_weighted_vol_avg * xlmbdai / xlmbda
        xlnrat = (
            3.0e0 * np.sqrt(np.pi) / 4.0e0 * me / constants.PROTON_MASS * sumln
        ) ** (2.0e0 / 3.0e0)
        ve = c * np.sqrt(2.0e0 * te / 511.0e0)

        ecritfi = (
            afast
            * constants.PROTON_MASS
            * ve
            * ve
            * xlnrat
            / (2.0e0 * constants.ELECTRON_CHARGE * 1.0e3)
        )

        x = np.sqrt(efast / ecritfi)
        t1 = np.log((x * x - x + 1.0e0) / ((x + 1.0e0) ** 2))
        thx = (2.0e0 * x - 1.0e0) / np.sqrt(3.0e0)
        t2 = 2.0e0 * np.sqrt(3.0e0) * (np.arctan(thx) + np.pi / 6.0e0)

        return (t1 + t2) / (3.0e0 * x * x)

    def xlmbdabi(self, mb, mth, eb, t, nelec):
        """Calculates the Coulomb logarithm for ion-ion collisions

        This function calculates the Coulomb logarithm for ion-ion
        collisions where the relative velocity may be large compared
        with the background ('mt') thermal velocity.
        Mikkelson and Singer, Nuc Tech/Fus, 4, 237 (1983)

        Parameters
        ----------
        mb:
            mass of fast particle (units of proton mass)
        mth:
            mass of background ions (units of proton mass)
        eb:
            energy of fast particle (keV)
        t:
            density weighted average electron temp. (keV)
        nelec:
            volume averaged electron density (m**-3)
        """

        x1 = (t / 10.0) * (eb / 1000.0) * mb / (nelec / 1e20)
        x2 = mth / (mth + mb)

        return 23.7 + np.log(x2 * np.sqrt(x1))

outfile = constants.NOUT instance-attribute

plasma_profile = plasma_profile instance-attribute

iternb()

Routine to calculate ITER Neutral Beam current drive parameters

Returns:

Name Type Description
effnbss

neutral beam current drive efficiency (A/W)

f_p_beam_injected_ions

fraction of NB power given to ions

fshine

shine-through fraction of beam

Notes

This routine calculates the current drive parameters for a neutral beam system, based on the 1990 ITER model. ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

Source code in process/models/physics/current_drive.py
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def iternb(self):
    """Routine to calculate ITER Neutral Beam current drive parameters

    Returns
    -------
    effnbss:
        neutral beam current drive efficiency (A/W)
    f_p_beam_injected_ions:
        fraction of NB power given to ions
    fshine:
         shine-through fraction of beam

    Notes
    -----
    This routine calculates the current drive parameters for a
    neutral beam system, based on the 1990 ITER model.
    ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
    ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990
    """
    # Check argument sanity
    if (
        1 + physics_variables.eps
    ) < current_drive_variables.f_radius_beam_tangency_rmajor:
        raise ProcessValueError(
            "Imminent negative square root argument; NBI will miss plasma completely",
            eps=physics_variables.eps,
            f_radius_beam_tangency_rmajor=current_drive_variables.f_radius_beam_tangency_rmajor,
        )

    # Calculate beam path length to centre
    dpath = physics_variables.rmajor * np.sqrt(
        (1.0 + physics_variables.eps) ** 2
        - current_drive_variables.f_radius_beam_tangency_rmajor**2
    )

    # Calculate beam stopping cross-section
    sigstop = self.sigbeam(
        current_drive_variables.e_beam_kev / physics_variables.m_beam_amu,
        physics_variables.temp_plasma_electron_vol_avg_kev,
        physics_variables.nd_plasma_electrons_vol_avg,
        physics_variables.f_nd_alpha_electron,
        physics_variables.f_nd_plasma_carbon_electron,
        physics_variables.f_nd_plasma_oxygen_electron,
        physics_variables.f_nd_plasma_iron_argon_electron,
    )

    # Calculate number of decay lengths to centre
    current_drive_variables.n_beam_decay_lengths_core = (
        dpath * physics_variables.nd_plasma_electrons_vol_avg * sigstop
    )

    # Shine-through fraction of beam
    fshine = np.exp(
        -2.0 * dpath * physics_variables.nd_plasma_electrons_vol_avg * sigstop
    )
    fshine = max(fshine, 1e-20)

    # Deuterium and tritium beam densities
    dend = physics_variables.nd_plasma_fuel_ions_vol_avg * (
        1.0 - current_drive_variables.f_beam_tritium
    )
    dent = (
        physics_variables.nd_plasma_fuel_ions_vol_avg
        * current_drive_variables.f_beam_tritium
    )

    # Power split to ions / electrons
    f_p_beam_injected_ions = self.cfnbi(
        physics_variables.m_beam_amu,
        current_drive_variables.e_beam_kev,
        physics_variables.temp_plasma_electron_density_weighted_kev,
        physics_variables.nd_plasma_electrons_vol_avg,
        dend,
        dent,
        physics_variables.n_charge_plasma_effective_mass_weighted_vol_avg,
        physics_variables.dlamie,
    )

    # Current drive efficiency
    effnbss = current_drive_variables.f_radius_beam_tangency_rmajor * self.etanb(
        physics_variables.m_beam_amu,
        physics_variables.alphan,
        physics_variables.alphat,
        physics_variables.aspect,
        physics_variables.nd_plasma_electrons_vol_avg,
        current_drive_variables.e_beam_kev,
        physics_variables.rmajor,
        physics_variables.temp_plasma_electron_density_weighted_kev,
        physics_variables.n_charge_plasma_effective_vol_avg,
    )

    return effnbss, f_p_beam_injected_ions, fshine

culnbi()

Routine to calculate Neutral Beam current drive parameters

Returns:

Name Type Description
effnbss

neutral beam current drive efficiency (A/W)

f_p_beam_injected_ions

fraction of NB power given to ions

fshine

shine-through fraction of beam

Notes

This routine calculates Neutral Beam current drive parameters using the corrections outlined in AEA FUS 172 to the ITER method.

The result cannot be guaranteed for devices with aspect ratios far from that of ITER (approx. 2.8). AEA FUS 172: Physics Assessment for the European Reactor Study

Source code in process/models/physics/current_drive.py
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
def culnbi(self):
    """Routine to calculate Neutral Beam current drive parameters

    Returns
    -------
    effnbss:
        neutral beam current drive efficiency (A/W)
    f_p_beam_injected_ions:
        fraction of NB power given to ions
    fshine:
        shine-through fraction of beam

    Notes
    -----
    This routine calculates Neutral Beam current drive parameters
    using the corrections outlined in AEA FUS 172 to the ITER method.
    <P>The result cannot be guaranteed for devices with aspect ratios far
    from that of ITER (approx. 2.8).
    AEA FUS 172: Physics Assessment for the European Reactor Study
    """
    if (
        1.0e0 + physics_variables.eps
    ) < current_drive_variables.f_radius_beam_tangency_rmajor:
        raise ProcessValueError(
            "Imminent negative square root argument; NBI will miss plasma completely",
            eps=physics_variables.eps,
            f_radius_beam_tangency_rmajor=current_drive_variables.f_radius_beam_tangency_rmajor,
        )

    #  Calculate beam path length to centre

    dpath = physics_variables.rmajor * np.sqrt(
        (1.0e0 + physics_variables.eps) ** 2
        - current_drive_variables.f_radius_beam_tangency_rmajor**2
    )

    #  Calculate beam stopping cross-section

    sigstop = self.sigbeam(
        current_drive_variables.e_beam_kev / physics_variables.m_beam_amu,
        physics_variables.temp_plasma_electron_vol_avg_kev,
        physics_variables.nd_plasma_electrons_vol_avg,
        physics_variables.f_nd_alpha_electron,
        physics_variables.f_nd_plasma_carbon_electron,
        physics_variables.f_nd_plasma_oxygen_electron,
        physics_variables.f_nd_plasma_iron_argon_electron,
    )

    #  Calculate number of decay lengths to centre

    current_drive_variables.n_beam_decay_lengths_core = (
        dpath * physics_variables.nd_plasma_electron_line * sigstop
    )

    #  Shine-through fraction of beam

    fshine = np.exp(
        -2.0e0 * dpath * physics_variables.nd_plasma_electron_line * sigstop
    )
    fshine = max(fshine, 1.0e-20)

    #  Deuterium and tritium beam densities

    dend = physics_variables.nd_plasma_fuel_ions_vol_avg * (
        1.0e0 - current_drive_variables.f_beam_tritium
    )
    dent = (
        physics_variables.nd_plasma_fuel_ions_vol_avg
        * current_drive_variables.f_beam_tritium
    )

    #  Power split to ions / electrons

    f_p_beam_injected_ions = self.cfnbi(
        physics_variables.m_beam_amu,
        current_drive_variables.e_beam_kev,
        physics_variables.temp_plasma_electron_density_weighted_kev,
        physics_variables.nd_plasma_electrons_vol_avg,
        dend,
        dent,
        physics_variables.n_charge_plasma_effective_mass_weighted_vol_avg,
        physics_variables.dlamie,
    )

    #  Current drive efficiency

    effnbss = self.etanb2(
        physics_variables.m_beam_amu,
        physics_variables.alphan,
        physics_variables.alphat,
        physics_variables.aspect,
        physics_variables.nd_plasma_electrons_vol_avg,
        physics_variables.nd_plasma_electron_line,
        current_drive_variables.e_beam_kev,
        current_drive_variables.f_radius_beam_tangency_rmajor,
        fshine,
        physics_variables.rmajor,
        physics_variables.rminor,
        physics_variables.temp_plasma_electron_density_weighted_kev,
        physics_variables.n_charge_plasma_effective_vol_avg,
    )

    return effnbss, f_p_beam_injected_ions, fshine

etanb2(m_beam_amu, alphan, alphat, aspect, nd_plasma_electrons_vol_avg, nd_plasma_electron_line, e_beam_kev, f_radius_beam_tangency_rmajor, fshine, rmajor, rminor, temp_plasma_electron_density_weighted_kev, zeff)

Routine to find neutral beam current drive efficiency using the ITER 1990 formulation, plus correction terms outlined in Culham Report AEA FUS 172

This routine calculates the current drive efficiency in A/W of a neutral beam system, based on the 1990 ITER model, plus correction terms outlined in Culham Report AEA FUS 172.

The formulae are from AEA FUS 172, unless denoted by IPDG89. AEA FUS 172: Physics Assessment for the European Reactor Study ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

Parameters:

Name Type Description Default
m_beam_amu

beam ion mass (amu)

required
alphan

density profile factor

required
alphat

temperature profile factor

required
aspect

aspect ratio

required
nd_plasma_electrons_vol_avg

volume averaged electron density (m**-3)

required
nd_plasma_electron_line

line averaged electron density (m**-3)

required
e_beam_kev

neutral beam energy (keV)

required
f_radius_beam_tangency_rmajor

R_tangent / R_major for neutral beam injection

required
fshine

shine-through fraction of beam

required
rmajor

plasma major radius (m)

required
rminor

plasma minor radius (m)

required
temp_plasma_electron_density_weighted_kev

density weighted average electron temperature (keV)

required
zeff

plasma effective charge

required
Source code in process/models/physics/current_drive.py
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
def etanb2(
    self,
    m_beam_amu,
    alphan,
    alphat,
    aspect,
    nd_plasma_electrons_vol_avg,
    nd_plasma_electron_line,
    e_beam_kev,
    f_radius_beam_tangency_rmajor,
    fshine,
    rmajor,
    rminor,
    temp_plasma_electron_density_weighted_kev,
    zeff,
):
    """Routine to find neutral beam current drive efficiency
    using the ITER 1990 formulation, plus correction terms
    outlined in Culham Report AEA FUS 172


    This routine calculates the current drive efficiency in A/W of
    a neutral beam system, based on the 1990 ITER model,
    plus correction terms outlined in Culham Report AEA FUS 172.
    <P>The formulae are from AEA FUS 172, unless denoted by IPDG89.
    AEA FUS 172: Physics Assessment for the European Reactor Study
    ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
    ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

    Parameters
    ----------
    m_beam_amu:
        beam ion mass (amu)
    alphan:
        density profile factor
    alphat:
        temperature profile factor
    aspect:
        aspect ratio
    nd_plasma_electrons_vol_avg:
        volume averaged electron density (m**-3)
    nd_plasma_electron_line:
        line averaged electron density (m**-3)
    e_beam_kev:
        neutral beam energy (keV)
    f_radius_beam_tangency_rmajor:
        R_tangent / R_major for neutral beam injection
    fshine:
        shine-through fraction of beam
    rmajor:
        plasma major radius (m)
    rminor:
        plasma minor radius (m)
    temp_plasma_electron_density_weighted_kev:
        density weighted average electron temperature (keV)
    zeff:
        plasma effective charge
    """
    #  Charge of beam ions
    zbeam = 1.0

    #  Fitting factor (IPDG89)
    bbd = 1.0

    #  Volume averaged electron density (10**20 m**-3)
    dene20 = nd_plasma_electrons_vol_avg / 1e20

    #  Line averaged electron density (10**20 m**-3)
    dnla20 = nd_plasma_electron_line / 1e20

    #  Critical energy (MeV) (power to electrons = power to ions) (IPDG89)
    #  N.B. temp_plasma_electron_density_weighted_kev is in keV
    ecrit = 0.01 * m_beam_amu * temp_plasma_electron_density_weighted_kev

    #  Beam energy in MeV
    ebmev = e_beam_kev / 1e3

    #  x and y coefficients of function J0(x,y) (IPDG89)
    xjs = ebmev / (bbd * ecrit)
    xj = np.sqrt(xjs)

    yj = 0.8 * zeff / m_beam_amu

    #  Fitting function J0(x,y)
    j0 = xjs / (4.0 + 3.0 * yj + xjs * (xj + 1.39 + 0.61 * yj**0.7))

    #  Effective inverse aspect ratio, with a limit on its maximum value
    epseff = min(0.2, (0.5 / aspect))

    #  Reduction in the reverse electron current
    #  due to neoclassical effects
    gfac = (1.55 + 0.85 / zeff) * np.sqrt(epseff) - (0.2 + 1.55 / zeff) * epseff

    # Reduction in the net beam driven current
    #  due to the reverse electron current
    ffac = 1.0 - (zbeam / zeff) * (1.0 - gfac)

    #  Normalisation to allow results to be valid for
    #  non-ITER plasma size and density:
    #  Line averaged electron density (10**20 m**-3) normalised to ITER
    nnorm = 1.0

    #  Distance along beam to plasma centre
    r = max(rmajor, rmajor * f_radius_beam_tangency_rmajor)
    eps1 = rminor / r

    if (1.0 + eps1) < f_radius_beam_tangency_rmajor:
        raise ProcessValueError(
            "Imminent negative square root argument; NBI will miss plasma completely",
            eps=eps1,
            f_radius_beam_tangency_rmajor=f_radius_beam_tangency_rmajor,
        )

    d = rmajor * np.sqrt((1.0 + eps1) ** 2 - f_radius_beam_tangency_rmajor**2)

    # Distance along beam to plasma centre for ITER
    # assuming a tangency radius equal to the major radius
    epsitr = 2.15 / 6.0
    dnorm = 6.0 * np.sqrt(2.0 * epsitr + epsitr**2)

    #  Normalisation to beam energy (assumes a simplified formula for
    #  the beam stopping cross-section)
    ebnorm = ebmev * ((nnorm * dnorm) / (dnla20 * d)) ** (1.0 / 0.78)

    #  A_bd fitting coefficient, after normalisation with ebnorm
    abd = (
        0.107
        * (1.0 - 0.35 * alphan + 0.14 * alphan**2)
        * (1.0 - 0.21 * alphat)
        * (1.0 - 0.2 * ebnorm + 0.09 * ebnorm**2)
    )

    #  Normalised current drive efficiency (A/W m**-2) (IPDG89)
    gamnb = (
        5.0
        * abd
        * 0.1
        * temp_plasma_electron_density_weighted_kev
        * (1.0 - fshine)
        * f_radius_beam_tangency_rmajor
        * j0
        / 0.2
        * ffac
    )

    #  Current drive efficiency (A/W)
    return gamnb / (dene20 * rmajor)

etanb(m_beam_amu, alphan, alphat, aspect, nd_plasma_electrons_vol_avg, ebeam, rmajor, temp_plasma_electron_density_weighted_kev, zeff)

Routine to find neutral beam current drive efficiency using the ITER 1990 formulation

Parameters:

Name Type Description Default
m_beam_amu

beam ion mass (amu)

required
alphan

density profile factor

required
alphat

temperature profile factor

required
aspect

aspect ratio

required
nd_plasma_electrons_vol_avg

volume averaged electron density (m**-3)

required
ebeam

neutral beam energy (keV)

required
rmajor

plasma major radius (m)

required
temp_plasma_electron_density_weighted_kev

density weighted average electron temp. (keV)

required
zeff

plasma effective charge

required
Notes

This routine calculates the current drive efficiency of a neutral beam system, based on the 1990 ITER model. ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

Source code in process/models/physics/current_drive.py
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
def etanb(
    self,
    m_beam_amu,
    alphan,
    alphat,
    aspect,
    nd_plasma_electrons_vol_avg,
    ebeam,
    rmajor,
    temp_plasma_electron_density_weighted_kev,
    zeff,
):
    """Routine to find neutral beam current drive efficiency
    using the ITER 1990 formulation

    Parameters
    ----------
    m_beam_amu:
        beam ion mass (amu)
    alphan:
        density profile factor
    alphat:
        temperature profile factor
    aspect:
        aspect ratio
    nd_plasma_electrons_vol_avg:
        volume averaged electron density (m**-3)
    ebeam:
        neutral beam energy (keV)
    rmajor:
        plasma major radius (m)
    temp_plasma_electron_density_weighted_kev:
        density weighted average electron temp. (keV)
    zeff:
        plasma effective charge

    Notes
    -----
    This routine calculates the current drive efficiency of
    a neutral beam system, based on the 1990 ITER model.
    ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
    ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990



    """

    zbeam = 1.0
    bbd = 1.0

    dene20 = 1e-20 * nd_plasma_electrons_vol_avg

    # Ratio of E_beam/E_crit
    xjs = ebeam / (
        bbd * 10.0 * m_beam_amu * temp_plasma_electron_density_weighted_kev
    )
    xj = np.sqrt(xjs)

    yj = 0.8 * zeff / m_beam_amu

    rjfunc = xjs / (4.0 + 3.0 * yj + xjs * (xj + 1.39 + 0.61 * yj**0.7))

    epseff = 0.5 / aspect
    gfac = (1.55 + 0.85 / zeff) * np.sqrt(epseff) - (0.2 + 1.55 / zeff) * epseff
    ffac = 1.0 / zbeam - (1.0 - gfac) / zeff

    abd = (
        0.107
        * (1.0 - 0.35 * alphan + 0.14 * alphan**2)
        * (1.0 - 0.21 * alphat)
        * (1.0 - 0.2e-3 * ebeam + 0.09e-6 * ebeam**2)
    )

    return (
        abd
        * (5.0 / rmajor)
        * (0.1 * temp_plasma_electron_density_weighted_kev / dene20)
        * rjfunc
        / 0.2
        * ffac
    )

sigbeam(eb, te, ne, rnhe, rnc, rno, rnfe)

Calculates the stopping cross-section for a hydrogen beam in a fusion plasma

Parameters:

Name Type Description Default
eb

beam energy (kev/amu)

required
te

electron temperature (keV)

required
ne

electron density (10^20m-3)

required
rnhe

alpha density / ne

required
rnc

carbon density /ne

required
rno

oxygen density /ne

required
rnfe

iron density /ne

required
Notes

This function calculates the stopping cross-section (m^-2) for a hydrogen beam in a fusion plasma. Janev, Boley and Post, Nuclear Fusion 29 (1989) 2125

Source code in process/models/physics/current_drive.py
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
def sigbeam(self, eb, te, ne, rnhe, rnc, rno, rnfe):
    """Calculates the stopping cross-section for a hydrogen
           beam in a fusion plasma

    Parameters
    ----------
    eb:
        beam energy (kev/amu)
    te:
        electron temperature (keV)
    ne:
        electron density (10^20m-3)
    rnhe:
        alpha density / ne
    rnc:
        carbon density /ne
    rno:
        oxygen density /ne
    rnfe:
        iron density /ne

    Notes
    -----
    This function calculates the stopping cross-section (m^-2)
    for a hydrogen beam in a fusion plasma.
    Janev, Boley and Post, Nuclear Fusion 29 (1989) 2125
    """
    a = np.array([
        [
            [4.4, -2.49e-2],
            [7.46e-2, 2.27e-3],
            [3.16e-3, -2.78e-5],
        ],
        [
            [2.3e-1, -1.15e-2],
            [-2.55e-3, -6.2e-4],
            [1.32e-3, 3.38e-5],
        ],
    ])

    b = np.array([
        [
            [[-2.36, -1.49, -1.41, -1.03], [0.185, -0.0154, -4.08e-4, 0.106]],
            [
                [-0.25, -0.119, -0.108, -0.0558],
                [-0.0381, -0.015, -0.0138, -3.72e-3],
            ],
        ],
        [
            [
                [0.849, 0.518, 0.477, 0.322],
                [-0.0478, 7.18e-3, 1.57e-3, -0.0375],
            ],
            [
                [0.0677, 0.0292, 0.0259, 0.0124],
                [0.0105, 3.66e-3, 3.33e-3, 8.61e-4],
            ],
        ],
        [
            [
                [-0.0588, -0.0336, -0.0305, -0.0187],
                [4.34e-3, 3.41e-4, 7.35e-4, 3.53e-3],
            ],
            [
                [-4.48e-3, -1.79e-3, -1.57e-3, -7.43e-4],
                [-6.76e-4, -2.04e-4, -1.86e-4, -5.12e-5],
            ],
        ],
    ])

    z = np.array([2.0, 6.0, 8.0, 26.0])
    nn = np.array([rnhe, rnc, rno, rnfe])

    nen = ne * 1e-19

    s1 = 0.0
    for k in range(2):
        for j in range(3):
            for i in range(2):
                s1 += (
                    a[i, j, k]
                    * (np.log(eb)) ** i
                    * (np.log(nen)) ** j
                    * (np.log(te)) ** k
                )

    sz = 0.0
    for l in range(4):  # noqa: E741
        for k in range(2):
            for j in range(2):
                for i in range(3):
                    sz += (
                        b[i, j, k, l]
                        * (np.log(eb)) ** i
                        * (np.log(nen)) ** j
                        * (np.log(te)) ** k
                        * nn[l]
                        * z[l]
                        * (z[l] - 1.0)
                    )

    return max(1e-20 * (np.exp(s1) / eb * (1.0 + sz)), 1e-23)

cfnbi(afast, efast, te, ne, _nd, _nt, n_charge_plasma_effective_mass_weighted_vol_avg, xlmbda)

Routine to calculate the fraction of the fast particle energy coupled to the ions

Parameters:

Name Type Description Default
afast

mass of fast particle (units of proton mass)

required
efast

energy of fast particle (keV)

required
te

density weighted average electron temp. (keV)

required
ne

volume averaged electron density (m**-3)

required
nd

deuterium beam density (m**-3)

required
nt

tritium beam density (m**-3)

required
n_charge_plasma_effective_mass_weighted_vol_avg

mass weighted plasma effective charge

required
xlmbda

ion-electron coulomb logarithm

required

Returns:

Name Type Description
f_p_beam_injected_ions

fraction of fast particle energy coupled to ions

Notes

This routine calculates the fast particle energy coupled to the ions in the neutral beam system.

Source code in process/models/physics/current_drive.py
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
def cfnbi(
    self,
    afast,
    efast,
    te,
    ne,
    _nd,
    _nt,
    n_charge_plasma_effective_mass_weighted_vol_avg,
    xlmbda,
):
    """Routine to calculate the fraction of the fast particle energy
     coupled to the ions

    Parameters
    ----------
    afast:
        mass of fast particle (units of proton mass)
    efast:
        energy of fast particle (keV)
    te:
        density weighted average electron temp. (keV)
    ne:
        volume averaged electron density (m**-3)
    nd:
        deuterium beam density (m**-3)
    nt:
        tritium beam density (m**-3)
    n_charge_plasma_effective_mass_weighted_vol_avg:
        mass weighted plasma effective charge
    xlmbda:
        ion-electron coulomb logarithm

    Returns
    -------
    f_p_beam_injected_ions:
         fraction of fast particle energy coupled to ions
    Notes
    -----
    This routine calculates the fast particle energy coupled to
    the ions in the neutral beam system.
    """
    # atmd = 2.0
    atmdt = 2.5
    # atmt = 3.0
    c = 3.0e8
    me = constants.ELECTRON_MASS
    # zd = 1.0
    # zt = 1.0

    # xlbd = self.xlmbdabi(afast, atmd, efast, te, ne)
    # xlbt = self.xlmbdabi(afast, atmt, efast, te, ne)

    # sum = nd * zd * zd * xlbd / atmd + nt * zt * zt * xlbt / atmt
    # ecritfix = 16.0e0 * te * afast * (sum / (ne * xlmbda)) ** (2.0e0 / 3.0e0)

    xlmbdai = self.xlmbdabi(afast, atmdt, efast, te, ne)
    sumln = n_charge_plasma_effective_mass_weighted_vol_avg * xlmbdai / xlmbda
    xlnrat = (
        3.0e0 * np.sqrt(np.pi) / 4.0e0 * me / constants.PROTON_MASS * sumln
    ) ** (2.0e0 / 3.0e0)
    ve = c * np.sqrt(2.0e0 * te / 511.0e0)

    ecritfi = (
        afast
        * constants.PROTON_MASS
        * ve
        * ve
        * xlnrat
        / (2.0e0 * constants.ELECTRON_CHARGE * 1.0e3)
    )

    x = np.sqrt(efast / ecritfi)
    t1 = np.log((x * x - x + 1.0e0) / ((x + 1.0e0) ** 2))
    thx = (2.0e0 * x - 1.0e0) / np.sqrt(3.0e0)
    t2 = 2.0e0 * np.sqrt(3.0e0) * (np.arctan(thx) + np.pi / 6.0e0)

    return (t1 + t2) / (3.0e0 * x * x)

xlmbdabi(mb, mth, eb, t, nelec)

Calculates the Coulomb logarithm for ion-ion collisions

This function calculates the Coulomb logarithm for ion-ion collisions where the relative velocity may be large compared with the background ('mt') thermal velocity. Mikkelson and Singer, Nuc Tech/Fus, 4, 237 (1983)

Parameters:

Name Type Description Default
mb

mass of fast particle (units of proton mass)

required
mth

mass of background ions (units of proton mass)

required
eb

energy of fast particle (keV)

required
t

density weighted average electron temp. (keV)

required
nelec

volume averaged electron density (m**-3)

required
Source code in process/models/physics/current_drive.py
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
def xlmbdabi(self, mb, mth, eb, t, nelec):
    """Calculates the Coulomb logarithm for ion-ion collisions

    This function calculates the Coulomb logarithm for ion-ion
    collisions where the relative velocity may be large compared
    with the background ('mt') thermal velocity.
    Mikkelson and Singer, Nuc Tech/Fus, 4, 237 (1983)

    Parameters
    ----------
    mb:
        mass of fast particle (units of proton mass)
    mth:
        mass of background ions (units of proton mass)
    eb:
        energy of fast particle (keV)
    t:
        density weighted average electron temp. (keV)
    nelec:
        volume averaged electron density (m**-3)
    """

    x1 = (t / 10.0) * (eb / 1000.0) * mb / (nelec / 1e20)
    x2 = mth / (mth + mb)

    return 23.7 + np.log(x2 * np.sqrt(x1))

ElectronCyclotron

Source code in process/models/physics/current_drive.py
 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
class ElectronCyclotron:
    def __init__(self, plasma_profile: PlasmaProfile):
        self.outfile = constants.NOUT
        self.plasma_profile = plasma_profile

    def culecd(self):
        """Routine to calculate Electron Cyclotron current drive efficiency

        This routine calculates the current drive parameters for a
        electron cyclotron system, based on the AEA FUS 172 model.
        AEA FUS 172: Physics Assessment for the European Reactor Study

        Returns
        -------
        :
            electron cyclotron current drive efficiency (A/W)
        """
        rrr = 1.0e0 / 3.0e0

        #  Temperature
        tlocal = self.plasma_profile.teprofile.calculate_profile_y(
            rrr,
            physics_variables.radius_plasma_pedestal_temp_norm,
            physics_variables.temp_plasma_electron_on_axis_kev,
            physics_variables.temp_plasma_pedestal_kev,
            physics_variables.temp_plasma_separatrix_kev,
            physics_variables.alphat,
            physics_variables.tbeta,
        )

        #  Density (10**20 m**-3)
        dlocal = 1.0e-20 * self.plasma_profile.neprofile.calculate_profile_y(
            rrr,
            physics_variables.radius_plasma_pedestal_density_norm,
            physics_variables.nd_plasma_electron_on_axis,
            physics_variables.nd_plasma_pedestal_electron,
            physics_variables.nd_plasma_separatrix_electron,
            physics_variables.alphan,
        )

        #  Inverse aspect ratio
        epsloc = rrr * physics_variables.rminor / physics_variables.rmajor

        #  Effective charge (use average value)
        zlocal = physics_variables.n_charge_plasma_effective_vol_avg

        #  Coulomb logarithm for ion-electron collisions
        #  (From J. A. Wesson, 'Tokamaks', Clarendon Press, Oxford, p.293)
        coulog = 15.2e0 - 0.5e0 * np.log(dlocal) + np.log(tlocal)

        #  Calculate normalised current drive efficiency at four different
        #  poloidal angles, and average.
        #  cosang = cosine of the poloidal angle at which ECCD takes place
        #         = +1 outside, -1 inside.
        cosang = 1.0e0
        ecgam1 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
        cosang = 0.5e0
        ecgam2 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
        cosang = -0.5e0
        ecgam3 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
        cosang = -1.0e0
        ecgam4 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)

        #  Normalised current drive efficiency (A/W m**-2)
        ecgam = 0.25e0 * (ecgam1 + ecgam2 + ecgam3 + ecgam4)

        #  Current drive efficiency (A/W)
        return ecgam / (dlocal * physics_variables.rmajor)

    def eccdef(self, tlocal, epsloc, zlocal, cosang, coulog):
        """Routine to calculate Electron Cyclotron current drive efficiency

        This routine calculates the current drive parameters for a
        electron cyclotron system, based on the AEA FUS 172 model.
        It works out the ECCD efficiency using the formula due to Cohen
        quoted in the ITER Physics Design Guidelines: 1989
        (but including division by the Coulomb Logarithm omitted from
        IPDG89). We have assumed gamma**2-1 << 1, where gamma is the
        relativistic factor. The notation follows that in IPDG89.
        <P>The answer ECGAM is the normalised efficiency nIR/P with n the
        local density in 10**20 /m**3, I the driven current in MAmps,
        R the major radius in metres, and P the absorbed power in MWatts.
        AEA FUS 172: Physics Assessment for the European Reactor Study
        ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
        ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

        Parameters
        ----------
        tlocal:
            local electron temperature (keV)
        epsloc:
            local inverse aspect ratio
        zlocal:
            local plasma effective charge
        cosang:
            cosine of the poloidal angle at which ECCD takes
            place (+1 outside, -1 inside)
        coulog:
            local coulomb logarithm for ion-electron collisions

        Returns
        -------
        ecgam:
             normalised current drive efficiency (A/W m**-2)
        """
        mcsq = (
            constants.ELECTRON_MASS * 2.9979e8**2 / (1.0e3 * constants.ELECTRON_VOLT)
        )  # keV
        f = 16.0e0 * (tlocal / mcsq) ** 2

        #  fp is the derivative of f with respect to gamma, the relativistic
        #  factor, taken equal to 1 + 2T/(m c**2)

        fp = 16.0e0 * tlocal / mcsq

        #  lam is IPDG89's lambda. LEGEND calculates the Legendre function of
        #  order alpha and argument lam, palpha, and its derivative, palphap.
        #  Here alpha satisfies alpha(alpha+1) = -8/(1+zlocal). alpha is of the
        #  form  (-1/2 + ix), with x a real number and i = sqrt(-1).

        lam = 1.0e0
        palpha, palphap = self.legend(zlocal, lam)

        lams = np.sqrt(2.0e0 * epsloc / (1.0e0 + epsloc))
        palphas, _ = self.legend(zlocal, lams)

        #  hp is the derivative of IPDG89's h function with respect to lam

        h = -4.0e0 * lam / (zlocal + 5.0e0) * (1.0e0 - lams * palpha / (lam * palphas))
        hp = -4.0e0 / (zlocal + 5.0e0) * (1.0e0 - lams * palphap / palphas)

        #  facm is IPDG89's momentum conserving factor

        facm = 1.5e0
        y = mcsq / (2.0e0 * tlocal) * (1.0e0 + epsloc * cosang)

        #  We take the negative of the IPDG89 expression to get a positive
        #  number

        ecgam = (
            -7.8e0
            * facm
            * np.sqrt((1.0e0 + epsloc) / (1.0e0 - epsloc))
            / coulog
            * (h * fp - 0.5e0 * y * f * hp)
        )

        if ecgam < 0.0e0:
            raise ProcessValueError("Negative normalised current drive efficiency")
        return ecgam

    def electron_cyclotron_fenstermacher(
        self,
        temp_plasma_electron_density_weighted_kev: float,
        rmajor: float,
        dene20: float,
        dlamee: float,
    ) -> float:
        """Routine to calculate Fenstermacher Electron Cyclotron heating efficiency.

        Parameters
        ----------
        temp_plasma_electron_density_weighted_kev: float
            Density weighted average electron temperature keV.
        zeff: float
            Plasma effective charge.
        rmajor: float
            Major radius of the plasma in meters.
        dene20: float
            Volume averaged electron density in 1x10^20 m^-3.
        dlamee: float
            Electron collision frequency in 1/s.

        Returns
        -------
        float
            The calculated electron cyclotron heating efficiency in A/W.

        references:
        - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.
        """

        return (0.21e0 * temp_plasma_electron_density_weighted_kev) / (
            rmajor * dene20 * dlamee
        )

    def electron_cyclotron_freethy(
        self,
        te: float,
        zeff: float,
        rmajor: float,
        nd_plasma_electrons_vol_avg: float,
        b_plasma_toroidal_on_axis: float,
        n_ecrh_harmonic: int,
        i_ecrh_wave_mode: int,
    ) -> float:
        """Calculate the Electron Cyclotron current drive efficiency using the Freethy model.

        This function computes the ECCD efficiency based on the electron temperature,
        effective charge, major radius, electron density, magnetic field, harmonic number,
        and wave mode.

        Parameters
        ----------
        te: float
            Volume averaged electron temperature in keV.
        zeff: float
            Plasma effective charge.
        rmajor: float
            Major radius of the plasma in meters.
        nd_plasma_electrons_vol_avg: float
            Volume averaged electron density in m^-3.
        b_plasma_toroidal_on_axis: float
            Toroidal magnetic field in Tesla.
        n_ecrh_harmonic: int
            Cyclotron harmonic number (fundamental used as default).
        i_ecrh_wave_mode: int
            Wave mode switch (0 for O-mode, 1 for X-mode).

        Returns
        -------
        float
            The calculated absolute ECCD efficiency in A/W.

        notes:
        - Plasma coupling only occurs if the plasma cut-off is below the cyclotron harmonic.
        - The density factor accounts for this behavior.

        references:
        - Freethy, S., PROCESS issue #2994.
        """

        # Cyclotron frequency
        fc = (
            1
            / (2 * np.pi)
            * constants.ELECTRON_CHARGE
            * b_plasma_toroidal_on_axis
            / constants.ELECTRON_MASS
        )

        # Plasma frequency
        fp = (
            1
            / (2 * np.pi)
            * np.sqrt(
                (nd_plasma_electrons_vol_avg)
                * constants.ELECTRON_CHARGE**2
                / (constants.ELECTRON_MASS * constants.EPSILON0)
            )
        )

        # Scaling factor for ECCD efficiency
        xi_CD = 0.18e0  # Tuned to the results of a GRAY study
        xi_CD *= 4.8e0 / (2 + zeff)  # Zeff correction

        # ECCD efficiency
        eta_cd = xi_CD * te / (3.27e0 * rmajor * (nd_plasma_electrons_vol_avg / 1.0e19))

        # Determine the cut-off frequency based on wave mode
        if i_ecrh_wave_mode == 0:  # O-mode case
            f_cutoff = fp
        elif i_ecrh_wave_mode == 1:  # X-mode case
            f_cutoff = 0.5 * (fc + np.sqrt(n_ecrh_harmonic * fc**2 + 4 * fp**2))
        else:
            raise ValueError("Invalid wave mode. Use 0 for O-mode or 1 for X-mode.")

        # Plasma coupling factor
        a = 0.1  # Controls sharpness of the transition
        cutoff_factor = 0.5 * (
            1 + np.tanh((2 / a) * ((n_ecrh_harmonic * fc - f_cutoff) / fp - a))
        )

        # Final ECCD efficiency
        return eta_cd * cutoff_factor

    def legend(self, zlocal, arg):
        """Routine to calculate Legendre function and its derivative

        This routine calculates the Legendre function <CODE>palpha</CODE>
        of argument <CODE>arg</CODE> and order
        <CODE>alpha = -0.5 + i sqrt(xisq)</CODE>,
        and its derivative <CODE>palphap</CODE>.
        <P>This Legendre function is a conical function and we use the series
        in <CODE>xisq</CODE> given in Abramowitz and Stegun. The
        derivative is calculated from the derivative of this series.
        <P>The derivatives were checked by calculating <CODE>palpha</CODE> for
        neighbouring arguments. The calculation of <CODE>palpha</CODE> for zero
        argument was checked by comparison with the expression
        <CODE>palpha(0) = 1/sqrt(pi) * cos(pi*alpha/2) * gam1 / gam2</CODE>
        (Abramowitz and Stegun, eqn 8.6.1). Here <CODE>gam1</CODE> and
        <CODE>gam2</CODE> are the Gamma functions of arguments
        <CODE>0.5*(1+alpha)</CODE> and <CODE>0.5*(2+alpha)</CODE> respectively.
        Abramowitz and Stegun, equation 8.12.1

        Parameters
        ----------
        zlocal:
             local plasma effective charge
        arg:
             argument of Legendre function

        Returns
        -------
        palphap:
            derivative of Legendre function
        palpha:
            value of Legendre function
        """
        if abs(arg) > (1.0e0 + 1.0e-10):
            raise ProcessValueError("Invalid argument", arg=arg)

        arg2 = min(arg, (1.0e0 - 1.0e-10))
        sinsq = 0.5e0 * (1.0e0 - arg2)
        xisq = 0.25e0 * (32.0e0 * zlocal / (zlocal + 1.0e0) - 1.0e0)
        palpha = 1.0e0
        pold = 1.0e0
        pterm = 1.0e0
        palphap = 0.0e0
        poldp = 0.0e0

        for n in range(10000):
            #  Check for convergence every 20 iterations

            if (n > 1) and ((n % 20) == 1):
                term1 = 1.0e-10 * max(abs(pold), abs(palpha))
                term2 = 1.0e-10 * max(abs(poldp), abs(palphap))

                if (abs(pold - palpha) < term1) and (abs(poldp - palphap) < term2):
                    return palpha, palphap

                pold = palpha
                poldp = palphap

            pterm = (
                pterm
                * (4.0e0 * xisq + (2.0e0 * n - 1.0e0) ** 2)
                / (2.0e0 * n) ** 2
                * sinsq
            )
            palpha = palpha + pterm
            palphap = palphap - n * pterm / (1.0e0 - arg2)
        else:
            raise ProcessError("legend: Solution has not converged")

outfile = constants.NOUT instance-attribute

plasma_profile = plasma_profile instance-attribute

culecd()

Routine to calculate Electron Cyclotron current drive efficiency

This routine calculates the current drive parameters for a electron cyclotron system, based on the AEA FUS 172 model. AEA FUS 172: Physics Assessment for the European Reactor Study

Returns:

Type Description

electron cyclotron current drive efficiency (A/W)

Source code in process/models/physics/current_drive.py
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
def culecd(self):
    """Routine to calculate Electron Cyclotron current drive efficiency

    This routine calculates the current drive parameters for a
    electron cyclotron system, based on the AEA FUS 172 model.
    AEA FUS 172: Physics Assessment for the European Reactor Study

    Returns
    -------
    :
        electron cyclotron current drive efficiency (A/W)
    """
    rrr = 1.0e0 / 3.0e0

    #  Temperature
    tlocal = self.plasma_profile.teprofile.calculate_profile_y(
        rrr,
        physics_variables.radius_plasma_pedestal_temp_norm,
        physics_variables.temp_plasma_electron_on_axis_kev,
        physics_variables.temp_plasma_pedestal_kev,
        physics_variables.temp_plasma_separatrix_kev,
        physics_variables.alphat,
        physics_variables.tbeta,
    )

    #  Density (10**20 m**-3)
    dlocal = 1.0e-20 * self.plasma_profile.neprofile.calculate_profile_y(
        rrr,
        physics_variables.radius_plasma_pedestal_density_norm,
        physics_variables.nd_plasma_electron_on_axis,
        physics_variables.nd_plasma_pedestal_electron,
        physics_variables.nd_plasma_separatrix_electron,
        physics_variables.alphan,
    )

    #  Inverse aspect ratio
    epsloc = rrr * physics_variables.rminor / physics_variables.rmajor

    #  Effective charge (use average value)
    zlocal = physics_variables.n_charge_plasma_effective_vol_avg

    #  Coulomb logarithm for ion-electron collisions
    #  (From J. A. Wesson, 'Tokamaks', Clarendon Press, Oxford, p.293)
    coulog = 15.2e0 - 0.5e0 * np.log(dlocal) + np.log(tlocal)

    #  Calculate normalised current drive efficiency at four different
    #  poloidal angles, and average.
    #  cosang = cosine of the poloidal angle at which ECCD takes place
    #         = +1 outside, -1 inside.
    cosang = 1.0e0
    ecgam1 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
    cosang = 0.5e0
    ecgam2 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
    cosang = -0.5e0
    ecgam3 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)
    cosang = -1.0e0
    ecgam4 = self.eccdef(tlocal, epsloc, zlocal, cosang, coulog)

    #  Normalised current drive efficiency (A/W m**-2)
    ecgam = 0.25e0 * (ecgam1 + ecgam2 + ecgam3 + ecgam4)

    #  Current drive efficiency (A/W)
    return ecgam / (dlocal * physics_variables.rmajor)

eccdef(tlocal, epsloc, zlocal, cosang, coulog)

Routine to calculate Electron Cyclotron current drive efficiency

This routine calculates the current drive parameters for a electron cyclotron system, based on the AEA FUS 172 model. It works out the ECCD efficiency using the formula due to Cohen quoted in the ITER Physics Design Guidelines: 1989 (but including division by the Coulomb Logarithm omitted from IPDG89). We have assumed gamma**2-1 << 1, where gamma is the relativistic factor. The notation follows that in IPDG89.

The answer ECGAM is the normalised efficiency nIR/P with n the local density in 10**20 /m**3, I the driven current in MAmps, R the major radius in metres, and P the absorbed power in MWatts. AEA FUS 172: Physics Assessment for the European Reactor Study ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al, ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

Parameters:

Name Type Description Default
tlocal

local electron temperature (keV)

required
epsloc

local inverse aspect ratio

required
zlocal

local plasma effective charge

required
cosang

cosine of the poloidal angle at which ECCD takes place (+1 outside, -1 inside)

required
coulog

local coulomb logarithm for ion-electron collisions

required

Returns:

Name Type Description
ecgam

normalised current drive efficiency (A/W m**-2)

Source code in process/models/physics/current_drive.py
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
def eccdef(self, tlocal, epsloc, zlocal, cosang, coulog):
    """Routine to calculate Electron Cyclotron current drive efficiency

    This routine calculates the current drive parameters for a
    electron cyclotron system, based on the AEA FUS 172 model.
    It works out the ECCD efficiency using the formula due to Cohen
    quoted in the ITER Physics Design Guidelines: 1989
    (but including division by the Coulomb Logarithm omitted from
    IPDG89). We have assumed gamma**2-1 << 1, where gamma is the
    relativistic factor. The notation follows that in IPDG89.
    <P>The answer ECGAM is the normalised efficiency nIR/P with n the
    local density in 10**20 /m**3, I the driven current in MAmps,
    R the major radius in metres, and P the absorbed power in MWatts.
    AEA FUS 172: Physics Assessment for the European Reactor Study
    ITER Physics Design Guidelines: 1989 [IPDG89], N. A. Uckan et al,
    ITER Documentation Series No.10, IAEA/ITER/DS/10, IAEA, Vienna, 1990

    Parameters
    ----------
    tlocal:
        local electron temperature (keV)
    epsloc:
        local inverse aspect ratio
    zlocal:
        local plasma effective charge
    cosang:
        cosine of the poloidal angle at which ECCD takes
        place (+1 outside, -1 inside)
    coulog:
        local coulomb logarithm for ion-electron collisions

    Returns
    -------
    ecgam:
         normalised current drive efficiency (A/W m**-2)
    """
    mcsq = (
        constants.ELECTRON_MASS * 2.9979e8**2 / (1.0e3 * constants.ELECTRON_VOLT)
    )  # keV
    f = 16.0e0 * (tlocal / mcsq) ** 2

    #  fp is the derivative of f with respect to gamma, the relativistic
    #  factor, taken equal to 1 + 2T/(m c**2)

    fp = 16.0e0 * tlocal / mcsq

    #  lam is IPDG89's lambda. LEGEND calculates the Legendre function of
    #  order alpha and argument lam, palpha, and its derivative, palphap.
    #  Here alpha satisfies alpha(alpha+1) = -8/(1+zlocal). alpha is of the
    #  form  (-1/2 + ix), with x a real number and i = sqrt(-1).

    lam = 1.0e0
    palpha, palphap = self.legend(zlocal, lam)

    lams = np.sqrt(2.0e0 * epsloc / (1.0e0 + epsloc))
    palphas, _ = self.legend(zlocal, lams)

    #  hp is the derivative of IPDG89's h function with respect to lam

    h = -4.0e0 * lam / (zlocal + 5.0e0) * (1.0e0 - lams * palpha / (lam * palphas))
    hp = -4.0e0 / (zlocal + 5.0e0) * (1.0e0 - lams * palphap / palphas)

    #  facm is IPDG89's momentum conserving factor

    facm = 1.5e0
    y = mcsq / (2.0e0 * tlocal) * (1.0e0 + epsloc * cosang)

    #  We take the negative of the IPDG89 expression to get a positive
    #  number

    ecgam = (
        -7.8e0
        * facm
        * np.sqrt((1.0e0 + epsloc) / (1.0e0 - epsloc))
        / coulog
        * (h * fp - 0.5e0 * y * f * hp)
    )

    if ecgam < 0.0e0:
        raise ProcessValueError("Negative normalised current drive efficiency")
    return ecgam

electron_cyclotron_fenstermacher(temp_plasma_electron_density_weighted_kev, rmajor, dene20, dlamee)

Routine to calculate Fenstermacher Electron Cyclotron heating efficiency.

Parameters:

Name Type Description Default
temp_plasma_electron_density_weighted_kev float

Density weighted average electron temperature keV.

required
zeff

Plasma effective charge.

required
rmajor float

Major radius of the plasma in meters.

required
dene20 float

Volume averaged electron density in 1x10^20 m^-3.

required
dlamee float

Electron collision frequency in 1/s.

required

Returns:

Name Type Description
float

The calculated electron cyclotron heating efficiency in A/W.

references float
- T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.
Source code in process/models/physics/current_drive.py
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
def electron_cyclotron_fenstermacher(
    self,
    temp_plasma_electron_density_weighted_kev: float,
    rmajor: float,
    dene20: float,
    dlamee: float,
) -> float:
    """Routine to calculate Fenstermacher Electron Cyclotron heating efficiency.

    Parameters
    ----------
    temp_plasma_electron_density_weighted_kev: float
        Density weighted average electron temperature keV.
    zeff: float
        Plasma effective charge.
    rmajor: float
        Major radius of the plasma in meters.
    dene20: float
        Volume averaged electron density in 1x10^20 m^-3.
    dlamee: float
        Electron collision frequency in 1/s.

    Returns
    -------
    float
        The calculated electron cyclotron heating efficiency in A/W.

    references:
    - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.
    """

    return (0.21e0 * temp_plasma_electron_density_weighted_kev) / (
        rmajor * dene20 * dlamee
    )

electron_cyclotron_freethy(te, zeff, rmajor, nd_plasma_electrons_vol_avg, b_plasma_toroidal_on_axis, n_ecrh_harmonic, i_ecrh_wave_mode)

Calculate the Electron Cyclotron current drive efficiency using the Freethy model.

This function computes the ECCD efficiency based on the electron temperature, effective charge, major radius, electron density, magnetic field, harmonic number, and wave mode.

Parameters:

Name Type Description Default
te float

Volume averaged electron temperature in keV.

required
zeff float

Plasma effective charge.

required
rmajor float

Major radius of the plasma in meters.

required
nd_plasma_electrons_vol_avg float

Volume averaged electron density in m^-3.

required
b_plasma_toroidal_on_axis float

Toroidal magnetic field in Tesla.

required
n_ecrh_harmonic int

Cyclotron harmonic number (fundamental used as default).

required
i_ecrh_wave_mode int

Wave mode switch (0 for O-mode, 1 for X-mode).

required

Returns:

Name Type Description
float

The calculated absolute ECCD efficiency in A/W.

notes float
- Plasma coupling only occurs if the plasma cut-off is below the cyclotron harmonic.
- The density factor accounts for this behavior.
references float
- Freethy, S., PROCESS issue #2994.
Source code in process/models/physics/current_drive.py
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
def electron_cyclotron_freethy(
    self,
    te: float,
    zeff: float,
    rmajor: float,
    nd_plasma_electrons_vol_avg: float,
    b_plasma_toroidal_on_axis: float,
    n_ecrh_harmonic: int,
    i_ecrh_wave_mode: int,
) -> float:
    """Calculate the Electron Cyclotron current drive efficiency using the Freethy model.

    This function computes the ECCD efficiency based on the electron temperature,
    effective charge, major radius, electron density, magnetic field, harmonic number,
    and wave mode.

    Parameters
    ----------
    te: float
        Volume averaged electron temperature in keV.
    zeff: float
        Plasma effective charge.
    rmajor: float
        Major radius of the plasma in meters.
    nd_plasma_electrons_vol_avg: float
        Volume averaged electron density in m^-3.
    b_plasma_toroidal_on_axis: float
        Toroidal magnetic field in Tesla.
    n_ecrh_harmonic: int
        Cyclotron harmonic number (fundamental used as default).
    i_ecrh_wave_mode: int
        Wave mode switch (0 for O-mode, 1 for X-mode).

    Returns
    -------
    float
        The calculated absolute ECCD efficiency in A/W.

    notes:
    - Plasma coupling only occurs if the plasma cut-off is below the cyclotron harmonic.
    - The density factor accounts for this behavior.

    references:
    - Freethy, S., PROCESS issue #2994.
    """

    # Cyclotron frequency
    fc = (
        1
        / (2 * np.pi)
        * constants.ELECTRON_CHARGE
        * b_plasma_toroidal_on_axis
        / constants.ELECTRON_MASS
    )

    # Plasma frequency
    fp = (
        1
        / (2 * np.pi)
        * np.sqrt(
            (nd_plasma_electrons_vol_avg)
            * constants.ELECTRON_CHARGE**2
            / (constants.ELECTRON_MASS * constants.EPSILON0)
        )
    )

    # Scaling factor for ECCD efficiency
    xi_CD = 0.18e0  # Tuned to the results of a GRAY study
    xi_CD *= 4.8e0 / (2 + zeff)  # Zeff correction

    # ECCD efficiency
    eta_cd = xi_CD * te / (3.27e0 * rmajor * (nd_plasma_electrons_vol_avg / 1.0e19))

    # Determine the cut-off frequency based on wave mode
    if i_ecrh_wave_mode == 0:  # O-mode case
        f_cutoff = fp
    elif i_ecrh_wave_mode == 1:  # X-mode case
        f_cutoff = 0.5 * (fc + np.sqrt(n_ecrh_harmonic * fc**2 + 4 * fp**2))
    else:
        raise ValueError("Invalid wave mode. Use 0 for O-mode or 1 for X-mode.")

    # Plasma coupling factor
    a = 0.1  # Controls sharpness of the transition
    cutoff_factor = 0.5 * (
        1 + np.tanh((2 / a) * ((n_ecrh_harmonic * fc - f_cutoff) / fp - a))
    )

    # Final ECCD efficiency
    return eta_cd * cutoff_factor

legend(zlocal, arg)

Routine to calculate Legendre function and its derivative

This routine calculates the Legendre function palpha of argument arg and order alpha = -0.5 + i sqrt(xisq), and its derivative palphap.

This Legendre function is a conical function and we use the series in xisq given in Abramowitz and Stegun. The derivative is calculated from the derivative of this series.

The derivatives were checked by calculating palpha for neighbouring arguments. The calculation of palpha for zero argument was checked by comparison with the expression palpha(0) = 1/sqrt(pi) * cos(pi*alpha/2) * gam1 / gam2 (Abramowitz and Stegun, eqn 8.6.1). Here gam1 and gam2 are the Gamma functions of arguments 0.5*(1+alpha) and 0.5*(2+alpha) respectively. Abramowitz and Stegun, equation 8.12.1

Parameters:

Name Type Description Default
zlocal

local plasma effective charge

required
arg

argument of Legendre function

required

Returns:

Name Type Description
palphap

derivative of Legendre function

palpha

value of Legendre function

Source code in process/models/physics/current_drive.py
 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
def legend(self, zlocal, arg):
    """Routine to calculate Legendre function and its derivative

    This routine calculates the Legendre function <CODE>palpha</CODE>
    of argument <CODE>arg</CODE> and order
    <CODE>alpha = -0.5 + i sqrt(xisq)</CODE>,
    and its derivative <CODE>palphap</CODE>.
    <P>This Legendre function is a conical function and we use the series
    in <CODE>xisq</CODE> given in Abramowitz and Stegun. The
    derivative is calculated from the derivative of this series.
    <P>The derivatives were checked by calculating <CODE>palpha</CODE> for
    neighbouring arguments. The calculation of <CODE>palpha</CODE> for zero
    argument was checked by comparison with the expression
    <CODE>palpha(0) = 1/sqrt(pi) * cos(pi*alpha/2) * gam1 / gam2</CODE>
    (Abramowitz and Stegun, eqn 8.6.1). Here <CODE>gam1</CODE> and
    <CODE>gam2</CODE> are the Gamma functions of arguments
    <CODE>0.5*(1+alpha)</CODE> and <CODE>0.5*(2+alpha)</CODE> respectively.
    Abramowitz and Stegun, equation 8.12.1

    Parameters
    ----------
    zlocal:
         local plasma effective charge
    arg:
         argument of Legendre function

    Returns
    -------
    palphap:
        derivative of Legendre function
    palpha:
        value of Legendre function
    """
    if abs(arg) > (1.0e0 + 1.0e-10):
        raise ProcessValueError("Invalid argument", arg=arg)

    arg2 = min(arg, (1.0e0 - 1.0e-10))
    sinsq = 0.5e0 * (1.0e0 - arg2)
    xisq = 0.25e0 * (32.0e0 * zlocal / (zlocal + 1.0e0) - 1.0e0)
    palpha = 1.0e0
    pold = 1.0e0
    pterm = 1.0e0
    palphap = 0.0e0
    poldp = 0.0e0

    for n in range(10000):
        #  Check for convergence every 20 iterations

        if (n > 1) and ((n % 20) == 1):
            term1 = 1.0e-10 * max(abs(pold), abs(palpha))
            term2 = 1.0e-10 * max(abs(poldp), abs(palphap))

            if (abs(pold - palpha) < term1) and (abs(poldp - palphap) < term2):
                return palpha, palphap

            pold = palpha
            poldp = palphap

        pterm = (
            pterm
            * (4.0e0 * xisq + (2.0e0 * n - 1.0e0) ** 2)
            / (2.0e0 * n) ** 2
            * sinsq
        )
        palpha = palpha + pterm
        palphap = palphap - n * pterm / (1.0e0 - arg2)
    else:
        raise ProcessError("legend: Solution has not converged")

IonCyclotron

Source code in process/models/physics/current_drive.py
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
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
class IonCyclotron:
    def __init__(self, plasma_profile: PlasmaProfile):
        self.outfile = constants.NOUT
        self.plasma_profile = plasma_profile

    def ion_cyclotron_ipdg89(
        self,
        temp_plasma_electron_density_weighted_kev: float,
        zeff: float,
        rmajor: float,
        dene20: float,
    ) -> float:
        """Routine to calculate IPDG89 Ion Cyclotron heating efficiency.

        This function computes the ion cyclotron heating efficiency based on
        the electron temperature, effective charge, major radius, and electron density.

        Parameters
        ----------
        temp_plasma_electron_density_weighted_kev: float
            Density weighted average electron temperature keV.
        zeff: float
            Plasma effective charge.
        rmajor: float
            Major radius of the plasma in meters.
        nd_plasma_electrons_vol_avg: float
            Volume averaged electron density in 1x10^20 m^-3.

        Returns
        -------
        float
            The calculated ion cyclotron heating efficiency in A/W.

        Notes
        -----
        - The 0.1 term is to convert the temperature into 10 keV units
        - The original formula is for the normalised current drive efficiency
        hence the addition of the density and majro radius terms to get back to an absolute value

        References
        ----------
        - N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989',
          https://inis.iaea.org/collection/NCLCollectionStore/_Public/21/068/21068960.pdf

        - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.
        """

        return (
            (0.63e0 * 0.1e0 * temp_plasma_electron_density_weighted_kev) / (2.0e0 + zeff)
        ) / (rmajor * dene20)

outfile = constants.NOUT instance-attribute

plasma_profile = plasma_profile instance-attribute

ion_cyclotron_ipdg89(temp_plasma_electron_density_weighted_kev, zeff, rmajor, dene20)

Routine to calculate IPDG89 Ion Cyclotron heating efficiency.

This function computes the ion cyclotron heating efficiency based on the electron temperature, effective charge, major radius, and electron density.

Parameters:

Name Type Description Default
temp_plasma_electron_density_weighted_kev float

Density weighted average electron temperature keV.

required
zeff float

Plasma effective charge.

required
rmajor float

Major radius of the plasma in meters.

required
nd_plasma_electrons_vol_avg

Volume averaged electron density in 1x10^20 m^-3.

required

Returns:

Type Description
float

The calculated ion cyclotron heating efficiency in A/W.

Notes
  • The 0.1 term is to convert the temperature into 10 keV units
  • The original formula is for the normalised current drive efficiency hence the addition of the density and majro radius terms to get back to an absolute value
References
Source code in process/models/physics/current_drive.py
1013
1014
1015
1016
1017
1018
1019
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
def ion_cyclotron_ipdg89(
    self,
    temp_plasma_electron_density_weighted_kev: float,
    zeff: float,
    rmajor: float,
    dene20: float,
) -> float:
    """Routine to calculate IPDG89 Ion Cyclotron heating efficiency.

    This function computes the ion cyclotron heating efficiency based on
    the electron temperature, effective charge, major radius, and electron density.

    Parameters
    ----------
    temp_plasma_electron_density_weighted_kev: float
        Density weighted average electron temperature keV.
    zeff: float
        Plasma effective charge.
    rmajor: float
        Major radius of the plasma in meters.
    nd_plasma_electrons_vol_avg: float
        Volume averaged electron density in 1x10^20 m^-3.

    Returns
    -------
    float
        The calculated ion cyclotron heating efficiency in A/W.

    Notes
    -----
    - The 0.1 term is to convert the temperature into 10 keV units
    - The original formula is for the normalised current drive efficiency
    hence the addition of the density and majro radius terms to get back to an absolute value

    References
    ----------
    - N.A. Uckan and ITER Physics Group, 'ITER Physics Design Guidelines: 1989',
      https://inis.iaea.org/collection/NCLCollectionStore/_Public/21/068/21068960.pdf

    - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.
    """

    return (
        (0.63e0 * 0.1e0 * temp_plasma_electron_density_weighted_kev) / (2.0e0 + zeff)
    ) / (rmajor * dene20)

ElectronBernstein

Source code in process/models/physics/current_drive.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
class ElectronBernstein:
    def __init__(self, plasma_profile: PlasmaProfile):
        self.outfile = constants.NOUT
        self.plasma_profile = plasma_profile

    def electron_bernstein_freethy(
        self,
        te: float,
        rmajor: float,
        dene20: float,
        b_plasma_toroidal_on_axis: float,
        n_ecrh_harmonic: int,
        xi_ebw: float,
    ) -> float:
        """Calculate the Electron Bernstein Wave (EBW) current drive efficiency using the Freethy model.

        This function computes the EBW current drive efficiency based on the electron temperature,
        major radius, electron density, magnetic field, harmonic number, and scaling factor.

        Parameters
        ----------
        te: float
            Volume averaged electron temperature in keV.
        rmajor: float
            Major radius of the plasma in meters.
        dene20: float
            Volume averaged electron density in units of 10^20 m^-3.
        b_plasma_toroidal_on_axis: float
            Toroidal magnetic field in Tesla.
        n_ecrh_harmonic: int
            Cyclotron harmonic number (fundamental used as default).
        xi_ebw: float
            Scaling factor for EBW efficiency.

        Returns
        -------
        float
            The calculated absolute EBW current drive efficiency in A/W.

        Notes
        -----
        - EBWs can only couple to plasma if the cyclotron harmonic is above the plasma density cut-off.
        - The density factor accounts for this behavior.

        References
        ----------
        - Freethy, S., PROCESS issue #1262.
        """

        # Normalised current drive efficiency gamma
        eta_cd_norm = (xi_ebw / 32.7e0) * te

        # Absolute current drive efficiency
        eta_cd = eta_cd_norm / (dene20 * rmajor)

        # EBWs can only couple to plasma if cyclotron harmonic is above plasma density cut-off;
        # this behavior is captured in the following function:
        # constant 'a' controls sharpness of transition
        a = 0.1e0

        fc = (
            1.0e0
            / (2.0e0 * np.pi)
            * n_ecrh_harmonic
            * constants.ELECTRON_CHARGE
            * b_plasma_toroidal_on_axis
            / constants.ELECTRON_MASS
        )

        fp = (
            1.0e0
            / (2.0e0 * np.pi)
            * np.sqrt(
                dene20
                * 1.0e20
                * constants.ELECTRON_CHARGE**2
                / (constants.ELECTRON_MASS * constants.EPSILON0)
            )
        )

        density_factor = 0.5e0 * (1.0e0 + np.tanh((2.0e0 / a) * ((fp - fc) / fp - a)))

        return eta_cd * density_factor

outfile = constants.NOUT instance-attribute

plasma_profile = plasma_profile instance-attribute

electron_bernstein_freethy(te, rmajor, dene20, b_plasma_toroidal_on_axis, n_ecrh_harmonic, xi_ebw)

Calculate the Electron Bernstein Wave (EBW) current drive efficiency using the Freethy model.

This function computes the EBW current drive efficiency based on the electron temperature, major radius, electron density, magnetic field, harmonic number, and scaling factor.

Parameters:

Name Type Description Default
te float

Volume averaged electron temperature in keV.

required
rmajor float

Major radius of the plasma in meters.

required
dene20 float

Volume averaged electron density in units of 10^20 m^-3.

required
b_plasma_toroidal_on_axis float

Toroidal magnetic field in Tesla.

required
n_ecrh_harmonic int

Cyclotron harmonic number (fundamental used as default).

required
xi_ebw float

Scaling factor for EBW efficiency.

required

Returns:

Type Description
float

The calculated absolute EBW current drive efficiency in A/W.

Notes
  • EBWs can only couple to plasma if the cyclotron harmonic is above the plasma density cut-off.
  • The density factor accounts for this behavior.
References
  • Freethy, S., PROCESS issue #1262.
Source code in process/models/physics/current_drive.py
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
def electron_bernstein_freethy(
    self,
    te: float,
    rmajor: float,
    dene20: float,
    b_plasma_toroidal_on_axis: float,
    n_ecrh_harmonic: int,
    xi_ebw: float,
) -> float:
    """Calculate the Electron Bernstein Wave (EBW) current drive efficiency using the Freethy model.

    This function computes the EBW current drive efficiency based on the electron temperature,
    major radius, electron density, magnetic field, harmonic number, and scaling factor.

    Parameters
    ----------
    te: float
        Volume averaged electron temperature in keV.
    rmajor: float
        Major radius of the plasma in meters.
    dene20: float
        Volume averaged electron density in units of 10^20 m^-3.
    b_plasma_toroidal_on_axis: float
        Toroidal magnetic field in Tesla.
    n_ecrh_harmonic: int
        Cyclotron harmonic number (fundamental used as default).
    xi_ebw: float
        Scaling factor for EBW efficiency.

    Returns
    -------
    float
        The calculated absolute EBW current drive efficiency in A/W.

    Notes
    -----
    - EBWs can only couple to plasma if the cyclotron harmonic is above the plasma density cut-off.
    - The density factor accounts for this behavior.

    References
    ----------
    - Freethy, S., PROCESS issue #1262.
    """

    # Normalised current drive efficiency gamma
    eta_cd_norm = (xi_ebw / 32.7e0) * te

    # Absolute current drive efficiency
    eta_cd = eta_cd_norm / (dene20 * rmajor)

    # EBWs can only couple to plasma if cyclotron harmonic is above plasma density cut-off;
    # this behavior is captured in the following function:
    # constant 'a' controls sharpness of transition
    a = 0.1e0

    fc = (
        1.0e0
        / (2.0e0 * np.pi)
        * n_ecrh_harmonic
        * constants.ELECTRON_CHARGE
        * b_plasma_toroidal_on_axis
        / constants.ELECTRON_MASS
    )

    fp = (
        1.0e0
        / (2.0e0 * np.pi)
        * np.sqrt(
            dene20
            * 1.0e20
            * constants.ELECTRON_CHARGE**2
            / (constants.ELECTRON_MASS * constants.EPSILON0)
        )
    )

    density_factor = 0.5e0 * (1.0e0 + np.tanh((2.0e0 / a) * ((fp - fc) / fp - a)))

    return eta_cd * density_factor

LowerHybrid

Source code in process/models/physics/current_drive.py
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
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
class LowerHybrid:
    def __init__(self, plasma_profile: PlasmaProfile):
        self.outfile = constants.NOUT
        self.plasma_profile = plasma_profile

    def cullhy(self):
        """Routine to calculate Lower Hybrid current drive efficiency

        effrfss: output real: lower hybrid current drive efficiency (A/W)
        This routine calculates the current drive parameters for a
        lower hybrid system, based on the AEA FUS 172 model.
        AEA FUS 172: Physics Assessment for the European Reactor Study
        """
        rratio = self.lhrad()
        rpenet = rratio * physics_variables.rminor

        # Local density, temperature, toroidal field at this minor radius

        dlocal = 1.0e-19 * self.plasma_profile.neprofile.calculate_profile_y(
            rratio,
            physics_variables.radius_plasma_pedestal_density_norm,
            physics_variables.nd_plasma_electron_on_axis,
            physics_variables.nd_plasma_pedestal_electron,
            physics_variables.nd_plasma_separatrix_electron,
            physics_variables.alphan,
        )
        tlocal = self.plasma_profile.teprofile.calculate_profile_y(
            rratio,
            physics_variables.radius_plasma_pedestal_temp_norm,
            physics_variables.temp_plasma_electron_on_axis_kev,
            physics_variables.temp_plasma_pedestal_kev,
            physics_variables.temp_plasma_separatrix_kev,
            physics_variables.alphat,
            physics_variables.tbeta,
        )
        blocal = (
            physics_variables.b_plasma_toroidal_on_axis
            * physics_variables.rmajor
            / (physics_variables.rmajor - rpenet)
        )  # Calculated on inboard side

        # Parallel refractive index needed for plasma access

        frac = np.sqrt(dlocal) / blocal
        nplacc = frac + np.sqrt(1.0e0 + frac * frac)

        # Local inverse aspect ratio

        epslh = rpenet / physics_variables.rmajor

        # LH normalised efficiency (A/W m**-2)

        x = 24.0e0 / (nplacc * np.sqrt(tlocal))

        term01 = 6.1e0 / (
            nplacc
            * nplacc
            * (physics_variables.n_charge_plasma_effective_vol_avg + 5.0e0)
        )
        term02 = 1.0e0 + (tlocal / 25.0e0) ** 1.16e0
        term03 = epslh**0.77e0 * np.sqrt(12.25e0 + x * x)
        term04 = 3.5e0 * epslh**0.77e0 + x

        if term03 > term04:
            raise ProcessValueError(
                "Normalised LH efficiency < 0; use a different value of i_hcd_primary",
                term03=term03,
                term04=term04,
            )

        gamlh = term01 * term02 * (1.0e0 - term03 / term04)

        # Current drive efficiency (A/W)

        return gamlh / ((0.1e0 * dlocal) * physics_variables.rmajor)

    def lhrad(self):
        """Routine to calculate Lower Hybrid wave absorption radius

        rratio: output real: minor radius of penetration / rminor
        This routine determines numerically the minor radius at which the
        damping of Lower Hybrid waves occurs, using a Newton-Raphson method.
        AEA FUS 172: Physics Assessment for the European Reactor Study
        """
        #  Correction to refractive index (kept within valid bounds)
        drfind = min(
            0.7e0,
            max(0.1e0, 12.5e0 / physics_variables.temp_plasma_electron_on_axis_kev),
        )

        #  Use Newton-Raphson method to establish the correct minor radius
        #  ratio. g is calculated as a function of r / r_minor, where g is
        #  the difference between the results of the two formulae for the
        #  energy E given in AEA FUS 172, p.58. The required minor radius
        #  ratio has been found when g is sufficiently close to zero.

        #  Initial guess for the minor radius ratio

        rat0 = 0.8e0

        for _ in range(100):
            #  Minor radius ratios either side of the latest guess

            r1 = rat0 - 1.0e-3 * rat0
            r2 = rat0 + 1.0e-3 * rat0

            #  Evaluate g at rat0, r1, r2

            g0 = self.lheval(drfind, rat0)
            g1 = self.lheval(drfind, r1)
            g2 = self.lheval(drfind, r2)

            #  Calculate gradient of g with respect to minor radius ratio

            dgdr = (g2 - g1) / (r2 - r1)

            #  New approximation

            rat1 = rat0 - g0 / dgdr

            #  Force this approximation to lie within bounds

            rat1 = max(0.0001e0, rat1)
            rat1 = min(0.9999e0, rat1)

            if abs(g0) <= 0.01e0:
                break
            rat0 = rat1

        else:
            logger.error(
                "LH penetration radius not found after lapno iterations, using 0.8*rminor"
            )
            rat0 = 0.8e0

        return rat0

    def lheval(self, drfind, rratio):
        """Routine to evaluate the difference between electron energy
        expressions required to find the Lower Hybrid absorption radius

        Parameters
        ----------
        drfind:
            correction to parallel refractive index
        rratio:
            guess for radius of penetration / rminor

        Returns
        -------
        ediff:
            difference between the E values (keV)

        Notes
        -----
        This routine evaluates the difference between the values calculated
        from the two equations for the electron energy E, given in
        AEA FUS 172, p.58. This difference is used to locate the Lower Hybrid
        wave absorption radius via a Newton-Raphson method, in calling
        routine <A HREF="lhrad.html">lhrad</A>.
        AEA FUS 172: Physics Assessment for the European Reactor Study
        """
        dlocal = 1.0e-19 * self.plasma_profile.neprofile.calculate_profile_y(
            rratio,
            physics_variables.radius_plasma_pedestal_density_norm,
            physics_variables.nd_plasma_electron_on_axis,
            physics_variables.nd_plasma_pedestal_electron,
            physics_variables.nd_plasma_separatrix_electron,
            physics_variables.alphan,
        )

        #  Local electron temperature

        tlocal = self.plasma_profile.teprofile.calculate_profile_y(
            rratio,
            physics_variables.radius_plasma_pedestal_temp_norm,
            physics_variables.temp_plasma_electron_on_axis_kev,
            physics_variables.temp_plasma_pedestal_kev,
            physics_variables.temp_plasma_separatrix_kev,
            physics_variables.alphat,
            physics_variables.tbeta,
        )

        #  Local toroidal field (evaluated at the inboard region of the flux surface)

        blocal = (
            physics_variables.b_plasma_toroidal_on_axis
            * physics_variables.rmajor
            / (physics_variables.rmajor - rratio * physics_variables.rminor)
        )

        #  Parallel refractive index needed for plasma access

        frac = np.sqrt(dlocal) / blocal
        nplacc = frac + np.sqrt(1.0e0 + frac * frac)

        #  Total parallel refractive index

        refind = nplacc + drfind

        #  First equation for electron energy E

        e1 = 511.0e0 * (np.sqrt(1.0e0 + 1.0e0 / (refind * refind)) - 1.0e0)

        #  Second equation for E

        e2 = 7.0e0 * tlocal

        #  Difference

        return e1 - e2

    def lower_hybrid_fenstermacher(
        self, te: float, rmajor: float, dene20: float
    ) -> float:
        """Calculate the lower hybrid frequency using the Fenstermacher formula.
        This function computes the lower hybrid frequency based on the electron
        temperature, major radius, and electron density.

        Parameters
        ----------
        te: float
            Volume averaged electron temperature in keV.
        rmajor: float
            Major radius of the plasma in meters.
        dene20: float
            Volume averaged electron density in units of 10^20 m^-3.

        Returns
        -------
        float
            The calculated absolute current drive efficiency in A/W.

        Notes
        -----
        - This forumla was originally in the Oak RidgeSystems Code, attributed to Fenstermacher
              and is used in the AEA FUS 172 report.

        References
        ----------
            - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.

            - R.L.Reid et al, Oak Ridge Report ORNL/FEDC-87-7, 1988
        """

        return (0.36e0 * (1.0e0 + (te / 25.0e0) ** 1.16e0)) / (rmajor * dene20)

    def lower_hybrid_ehst(
        self, te: float, beta: float, rmajor: float, dene20: float, zeff: float
    ) -> float:
        """Calculate the Lower Hybrid current drive efficiency using the Ehst model.

        This function computes the current drive efficiency based on the electron
        temperature, beta, major radius, electron density, and effective charge.

        Parameters
        ----------
        te: float
            Volume averaged electron temperature in keV.
        beta: float
            Plasma beta value (ratio of plasma pressure to magnetic pressure).
        rmajor: float
            Major radius of the plasma in meters.
        dene20: float
            Volume averaged electron density in units of 10^20 m^-3.
        zeff: float
            Plasma effective charge.

        Returns
        -------
        float
            The calculated absolute current drive efficiency in A/W.


        References
        ----------
            - Ehst, D.A., and Karney, C.F.F., "Lower Hybrid Current Drive in Tokamaks",
              Nuclear Fusion, 31(10), 1933-1949, 1991.
        """
        return (
            ((te**0.77 * (0.034 + 0.196 * beta)) / (rmajor * dene20))
            * (
                32.0 / (5.0 + zeff)
                + 2.0
                + (12.0 * (6.0 + zeff)) / (5.0 + zeff) / (3.0 + zeff)
                + 3.76 / zeff
            )
            / 12.507
        )

outfile = constants.NOUT instance-attribute

plasma_profile = plasma_profile instance-attribute

cullhy()

Routine to calculate Lower Hybrid current drive efficiency

effrfss: output real: lower hybrid current drive efficiency (A/W) This routine calculates the current drive parameters for a lower hybrid system, based on the AEA FUS 172 model. AEA FUS 172: Physics Assessment for the European Reactor Study

Source code in process/models/physics/current_drive.py
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
def cullhy(self):
    """Routine to calculate Lower Hybrid current drive efficiency

    effrfss: output real: lower hybrid current drive efficiency (A/W)
    This routine calculates the current drive parameters for a
    lower hybrid system, based on the AEA FUS 172 model.
    AEA FUS 172: Physics Assessment for the European Reactor Study
    """
    rratio = self.lhrad()
    rpenet = rratio * physics_variables.rminor

    # Local density, temperature, toroidal field at this minor radius

    dlocal = 1.0e-19 * self.plasma_profile.neprofile.calculate_profile_y(
        rratio,
        physics_variables.radius_plasma_pedestal_density_norm,
        physics_variables.nd_plasma_electron_on_axis,
        physics_variables.nd_plasma_pedestal_electron,
        physics_variables.nd_plasma_separatrix_electron,
        physics_variables.alphan,
    )
    tlocal = self.plasma_profile.teprofile.calculate_profile_y(
        rratio,
        physics_variables.radius_plasma_pedestal_temp_norm,
        physics_variables.temp_plasma_electron_on_axis_kev,
        physics_variables.temp_plasma_pedestal_kev,
        physics_variables.temp_plasma_separatrix_kev,
        physics_variables.alphat,
        physics_variables.tbeta,
    )
    blocal = (
        physics_variables.b_plasma_toroidal_on_axis
        * physics_variables.rmajor
        / (physics_variables.rmajor - rpenet)
    )  # Calculated on inboard side

    # Parallel refractive index needed for plasma access

    frac = np.sqrt(dlocal) / blocal
    nplacc = frac + np.sqrt(1.0e0 + frac * frac)

    # Local inverse aspect ratio

    epslh = rpenet / physics_variables.rmajor

    # LH normalised efficiency (A/W m**-2)

    x = 24.0e0 / (nplacc * np.sqrt(tlocal))

    term01 = 6.1e0 / (
        nplacc
        * nplacc
        * (physics_variables.n_charge_plasma_effective_vol_avg + 5.0e0)
    )
    term02 = 1.0e0 + (tlocal / 25.0e0) ** 1.16e0
    term03 = epslh**0.77e0 * np.sqrt(12.25e0 + x * x)
    term04 = 3.5e0 * epslh**0.77e0 + x

    if term03 > term04:
        raise ProcessValueError(
            "Normalised LH efficiency < 0; use a different value of i_hcd_primary",
            term03=term03,
            term04=term04,
        )

    gamlh = term01 * term02 * (1.0e0 - term03 / term04)

    # Current drive efficiency (A/W)

    return gamlh / ((0.1e0 * dlocal) * physics_variables.rmajor)

lhrad()

Routine to calculate Lower Hybrid wave absorption radius

rratio: output real: minor radius of penetration / rminor This routine determines numerically the minor radius at which the damping of Lower Hybrid waves occurs, using a Newton-Raphson method. AEA FUS 172: Physics Assessment for the European Reactor Study

Source code in process/models/physics/current_drive.py
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
def lhrad(self):
    """Routine to calculate Lower Hybrid wave absorption radius

    rratio: output real: minor radius of penetration / rminor
    This routine determines numerically the minor radius at which the
    damping of Lower Hybrid waves occurs, using a Newton-Raphson method.
    AEA FUS 172: Physics Assessment for the European Reactor Study
    """
    #  Correction to refractive index (kept within valid bounds)
    drfind = min(
        0.7e0,
        max(0.1e0, 12.5e0 / physics_variables.temp_plasma_electron_on_axis_kev),
    )

    #  Use Newton-Raphson method to establish the correct minor radius
    #  ratio. g is calculated as a function of r / r_minor, where g is
    #  the difference between the results of the two formulae for the
    #  energy E given in AEA FUS 172, p.58. The required minor radius
    #  ratio has been found when g is sufficiently close to zero.

    #  Initial guess for the minor radius ratio

    rat0 = 0.8e0

    for _ in range(100):
        #  Minor radius ratios either side of the latest guess

        r1 = rat0 - 1.0e-3 * rat0
        r2 = rat0 + 1.0e-3 * rat0

        #  Evaluate g at rat0, r1, r2

        g0 = self.lheval(drfind, rat0)
        g1 = self.lheval(drfind, r1)
        g2 = self.lheval(drfind, r2)

        #  Calculate gradient of g with respect to minor radius ratio

        dgdr = (g2 - g1) / (r2 - r1)

        #  New approximation

        rat1 = rat0 - g0 / dgdr

        #  Force this approximation to lie within bounds

        rat1 = max(0.0001e0, rat1)
        rat1 = min(0.9999e0, rat1)

        if abs(g0) <= 0.01e0:
            break
        rat0 = rat1

    else:
        logger.error(
            "LH penetration radius not found after lapno iterations, using 0.8*rminor"
        )
        rat0 = 0.8e0

    return rat0

lheval(drfind, rratio)

Routine to evaluate the difference between electron energy expressions required to find the Lower Hybrid absorption radius

Parameters:

Name Type Description Default
drfind

correction to parallel refractive index

required
rratio

guess for radius of penetration / rminor

required

Returns:

Name Type Description
ediff

difference between the E values (keV)

Notes

This routine evaluates the difference between the values calculated from the two equations for the electron energy E, given in AEA FUS 172, p.58. This difference is used to locate the Lower Hybrid wave absorption radius via a Newton-Raphson method, in calling routine lhrad. AEA FUS 172: Physics Assessment for the European Reactor Study

Source code in process/models/physics/current_drive.py
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
def lheval(self, drfind, rratio):
    """Routine to evaluate the difference between electron energy
    expressions required to find the Lower Hybrid absorption radius

    Parameters
    ----------
    drfind:
        correction to parallel refractive index
    rratio:
        guess for radius of penetration / rminor

    Returns
    -------
    ediff:
        difference between the E values (keV)

    Notes
    -----
    This routine evaluates the difference between the values calculated
    from the two equations for the electron energy E, given in
    AEA FUS 172, p.58. This difference is used to locate the Lower Hybrid
    wave absorption radius via a Newton-Raphson method, in calling
    routine <A HREF="lhrad.html">lhrad</A>.
    AEA FUS 172: Physics Assessment for the European Reactor Study
    """
    dlocal = 1.0e-19 * self.plasma_profile.neprofile.calculate_profile_y(
        rratio,
        physics_variables.radius_plasma_pedestal_density_norm,
        physics_variables.nd_plasma_electron_on_axis,
        physics_variables.nd_plasma_pedestal_electron,
        physics_variables.nd_plasma_separatrix_electron,
        physics_variables.alphan,
    )

    #  Local electron temperature

    tlocal = self.plasma_profile.teprofile.calculate_profile_y(
        rratio,
        physics_variables.radius_plasma_pedestal_temp_norm,
        physics_variables.temp_plasma_electron_on_axis_kev,
        physics_variables.temp_plasma_pedestal_kev,
        physics_variables.temp_plasma_separatrix_kev,
        physics_variables.alphat,
        physics_variables.tbeta,
    )

    #  Local toroidal field (evaluated at the inboard region of the flux surface)

    blocal = (
        physics_variables.b_plasma_toroidal_on_axis
        * physics_variables.rmajor
        / (physics_variables.rmajor - rratio * physics_variables.rminor)
    )

    #  Parallel refractive index needed for plasma access

    frac = np.sqrt(dlocal) / blocal
    nplacc = frac + np.sqrt(1.0e0 + frac * frac)

    #  Total parallel refractive index

    refind = nplacc + drfind

    #  First equation for electron energy E

    e1 = 511.0e0 * (np.sqrt(1.0e0 + 1.0e0 / (refind * refind)) - 1.0e0)

    #  Second equation for E

    e2 = 7.0e0 * tlocal

    #  Difference

    return e1 - e2

lower_hybrid_fenstermacher(te, rmajor, dene20)

Calculate the lower hybrid frequency using the Fenstermacher formula. This function computes the lower hybrid frequency based on the electron temperature, major radius, and electron density.

Parameters:

Name Type Description Default
te float

Volume averaged electron temperature in keV.

required
rmajor float

Major radius of the plasma in meters.

required
dene20 float

Volume averaged electron density in units of 10^20 m^-3.

required

Returns:

Type Description
float

The calculated absolute current drive efficiency in A/W.

Notes
  • This forumla was originally in the Oak RidgeSystems Code, attributed to Fenstermacher and is used in the AEA FUS 172 report.
References
- T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.

- R.L.Reid et al, Oak Ridge Report ORNL/FEDC-87-7, 1988
Source code in process/models/physics/current_drive.py
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
def lower_hybrid_fenstermacher(
    self, te: float, rmajor: float, dene20: float
) -> float:
    """Calculate the lower hybrid frequency using the Fenstermacher formula.
    This function computes the lower hybrid frequency based on the electron
    temperature, major radius, and electron density.

    Parameters
    ----------
    te: float
        Volume averaged electron temperature in keV.
    rmajor: float
        Major radius of the plasma in meters.
    dene20: float
        Volume averaged electron density in units of 10^20 m^-3.

    Returns
    -------
    float
        The calculated absolute current drive efficiency in A/W.

    Notes
    -----
    - This forumla was originally in the Oak RidgeSystems Code, attributed to Fenstermacher
          and is used in the AEA FUS 172 report.

    References
    ----------
        - T.C. Hender et al., 'Physics Assessment of the European Reactor Study', AEA FUS 172, 1992.

        - R.L.Reid et al, Oak Ridge Report ORNL/FEDC-87-7, 1988
    """

    return (0.36e0 * (1.0e0 + (te / 25.0e0) ** 1.16e0)) / (rmajor * dene20)

lower_hybrid_ehst(te, beta, rmajor, dene20, zeff)

Calculate the Lower Hybrid current drive efficiency using the Ehst model.

This function computes the current drive efficiency based on the electron temperature, beta, major radius, electron density, and effective charge.

Parameters:

Name Type Description Default
te float

Volume averaged electron temperature in keV.

required
beta float

Plasma beta value (ratio of plasma pressure to magnetic pressure).

required
rmajor float

Major radius of the plasma in meters.

required
dene20 float

Volume averaged electron density in units of 10^20 m^-3.

required
zeff float

Plasma effective charge.

required

Returns:

Type Description
float

The calculated absolute current drive efficiency in A/W.

References
- Ehst, D.A., and Karney, C.F.F., "Lower Hybrid Current Drive in Tokamaks",
  Nuclear Fusion, 31(10), 1933-1949, 1991.
Source code in process/models/physics/current_drive.py
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
def lower_hybrid_ehst(
    self, te: float, beta: float, rmajor: float, dene20: float, zeff: float
) -> float:
    """Calculate the Lower Hybrid current drive efficiency using the Ehst model.

    This function computes the current drive efficiency based on the electron
    temperature, beta, major radius, electron density, and effective charge.

    Parameters
    ----------
    te: float
        Volume averaged electron temperature in keV.
    beta: float
        Plasma beta value (ratio of plasma pressure to magnetic pressure).
    rmajor: float
        Major radius of the plasma in meters.
    dene20: float
        Volume averaged electron density in units of 10^20 m^-3.
    zeff: float
        Plasma effective charge.

    Returns
    -------
    float
        The calculated absolute current drive efficiency in A/W.


    References
    ----------
        - Ehst, D.A., and Karney, C.F.F., "Lower Hybrid Current Drive in Tokamaks",
          Nuclear Fusion, 31(10), 1933-1949, 1991.
    """
    return (
        ((te**0.77 * (0.034 + 0.196 * beta)) / (rmajor * dene20))
        * (
            32.0 / (5.0 + zeff)
            + 2.0
            + (12.0 * (6.0 + zeff)) / (5.0 + zeff) / (3.0 + zeff)
            + 3.76 / zeff
        )
        / 12.507
    )

CurrentDrive

Source code in process/models/physics/current_drive.py
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
class CurrentDrive:
    def __init__(
        self,
        plasma_profile: PlasmaProfile,
        electron_cyclotron: ElectronCyclotron,
        ion_cyclotron: IonCyclotron,
        lower_hybrid: LowerHybrid,
        neutral_beam: NeutralBeam,
        electron_bernstein: ElectronBernstein,
    ):
        self.outfile = constants.NOUT
        self.mfile = constants.MFILE
        self.plasma_profile = plasma_profile
        self.electron_cyclotron = electron_cyclotron
        self.ion_cyclotron = ion_cyclotron
        self.lower_hybrid = lower_hybrid
        self.neutral_beam = neutral_beam
        self.electron_bernstein = electron_bernstein

    def cudriv(self):
        """Calculate the current drive power requirements.

        This method computes the power requirements of the current drive system
        using a choice of models for the current drive efficiency.

        Parameters
        ----------
        output: bool
            Flag indicating whether to write results to the output file.

        Raises
        ------
        ProcessValueError
            If an invalid current drive switch is encountered.
        """

        current_drive_variables.p_hcd_ecrh_injected_total_mw = 0.0e0
        current_drive_variables.p_hcd_beam_injected_total_mw = 0.0e0
        current_drive_variables.p_hcd_lowhyb_injected_total_mw = 0.0e0
        current_drive_variables.p_hcd_icrh_injected_total_mw = 0.0e0
        current_drive_variables.p_hcd_ebw_injected_total_mw = 0.0e0
        current_drive_variables.c_beam_total = 0.0e0
        current_drive_variables.p_beam_orbit_loss_mw = 0.0e0

        pinjmw1 = 0.0
        p_hcd_primary_ions_mw = 0.0
        p_hcd_primary_electrons_mw = 0.0
        p_hcd_secondary_electrons_mw = 0.0
        p_hcd_secondary_ions_mw = 0.0

        # To stop issues with input file we force
        # zero secondary heating if no injection method
        if current_drive_variables.i_hcd_secondary == 0:
            current_drive_variables.p_hcd_secondary_extra_heat_mw = 0.0

        # i_hcd_calculations |  switch for current drive calculation
        # = 0   |  turned off
        # = 1   |  turned on

        if current_drive_variables.i_hcd_calculations != 0:
            # Put electron density in desired units (10^-20 m-3)
            dene20 = physics_variables.nd_plasma_electrons_vol_avg * 1.0e-20

            # Calculate current drive efficiencies
            # ==============================================================

            # Define a dictionary of lambda functions for current drive efficiency models
            hcd_models = {
                1: lambda: (
                    self.lower_hybrid.lower_hybrid_fenstermacher(
                        physics_variables.temp_plasma_electron_vol_avg_kev,
                        physics_variables.rmajor,
                        dene20,
                    )
                    * current_drive_variables.feffcd
                ),
                2: lambda: (
                    self.ion_cyclotron.ion_cyclotron_ipdg89(
                        temp_plasma_electron_density_weighted_kev=physics_variables.temp_plasma_electron_density_weighted_kev,
                        zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                        rmajor=physics_variables.rmajor,
                        dene20=dene20,
                    )
                    * current_drive_variables.feffcd
                ),
                3: lambda: (
                    self.electron_cyclotron.electron_cyclotron_fenstermacher(
                        temp_plasma_electron_density_weighted_kev=physics_variables.temp_plasma_electron_density_weighted_kev,
                        rmajor=physics_variables.rmajor,
                        dene20=dene20,
                        dlamee=physics_variables.dlamee,
                    )
                    * current_drive_variables.feffcd
                ),
                4: lambda: (
                    self.lower_hybrid.lower_hybrid_ehst(
                        te=physics_variables.temp_plasma_electron_vol_avg_kev,
                        beta=physics_variables.beta_total_vol_avg,
                        rmajor=physics_variables.rmajor,
                        dene20=dene20,
                        zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                    )
                    * current_drive_variables.feffcd
                ),
                5: lambda: (
                    self.neutral_beam.iternb()[0] * current_drive_variables.feffcd
                ),
                6: lambda: self.lower_hybrid.cullhy() * current_drive_variables.feffcd,
                7: lambda: (
                    self.electron_cyclotron.culecd() * current_drive_variables.feffcd
                ),
                8: lambda: (
                    self.neutral_beam.culnbi()[0] * current_drive_variables.feffcd
                ),
                10: lambda: (
                    current_drive_variables.eta_cd_norm_ecrh
                    / (dene20 * physics_variables.rmajor)
                ),
                12: lambda: (
                    self.electron_bernstein.electron_bernstein_freethy(
                        te=physics_variables.temp_plasma_electron_vol_avg_kev,
                        rmajor=physics_variables.rmajor,
                        dene20=dene20,
                        b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
                        n_ecrh_harmonic=current_drive_variables.n_ecrh_harmonic,
                        xi_ebw=current_drive_variables.xi_ebw,
                    )
                    * current_drive_variables.feffcd
                ),
                13: lambda: (
                    self.electron_cyclotron.electron_cyclotron_freethy(
                        te=physics_variables.temp_plasma_electron_vol_avg_kev,
                        zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                        rmajor=physics_variables.rmajor,
                        nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
                        b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
                        n_ecrh_harmonic=current_drive_variables.n_ecrh_harmonic,
                        i_ecrh_wave_mode=current_drive_variables.i_ecrh_wave_mode,
                    )
                    * current_drive_variables.feffcd
                ),
            }

            # Assign outputs for models that return multiple values
            if current_drive_variables.i_hcd_secondary in [5, 8]:
                _, f_p_beam_injected_ions, f_p_beam_shine_through = (
                    self.neutral_beam.iternb()
                    if current_drive_variables.i_hcd_secondary == 5
                    else self.neutral_beam.culnbi()
                )
                current_drive_variables.f_p_beam_injected_ions = f_p_beam_injected_ions
                current_drive_variables.f_p_beam_shine_through = f_p_beam_shine_through

            # Calculate eta_cd_hcd_secondary based on the selected model
            if current_drive_variables.i_hcd_secondary in hcd_models:
                current_drive_variables.eta_cd_hcd_secondary = hcd_models[
                    current_drive_variables.i_hcd_secondary
                ]()
            elif current_drive_variables.i_hcd_secondary != 0:
                raise ProcessValueError(
                    f"Current drive switch is invalid: {current_drive_variables.i_hcd_secondary = }"
                )

            # Calculate eta_cd_hcd_primary based on the selected model
            if current_drive_variables.i_hcd_primary in hcd_models:
                current_drive_variables.eta_cd_hcd_primary = hcd_models[
                    current_drive_variables.i_hcd_primary
                ]()
            else:
                raise ProcessValueError(
                    f"Current drive switch is invalid: {current_drive_variables.i_hcd_primary = }"
                )

            # Calculate the normalised current drive efficieny for the primary heating method
            current_drive_variables.eta_cd_norm_hcd_primary = (
                current_drive_variables.eta_cd_hcd_primary
                * (dene20 * physics_variables.rmajor)
            )
            # Calculate the normalised current drive efficieny for the secondary heating method
            current_drive_variables.eta_cd_norm_hcd_secondary = (
                current_drive_variables.eta_cd_hcd_secondary
                * (dene20 * physics_variables.rmajor)
            )

            # Calculate the driven current for the secondary heating method
            current_drive_variables.c_hcd_secondary_driven = (
                current_drive_variables.eta_cd_hcd_secondary
                * current_drive_variables.p_hcd_secondary_injected_mw
                * 1.0e6
            )
            # Calculate the fraction of the plasma current driven by the secondary heating method
            current_drive_variables.f_c_plasma_hcd_secondary = (
                current_drive_variables.c_hcd_secondary_driven
                / physics_variables.plasma_current
            )

            # Calculate the injected power for the primary heating method
            current_drive_variables.p_hcd_primary_injected_mw = (
                1.0e-6
                * (
                    physics_variables.f_c_plasma_auxiliary
                    - current_drive_variables.f_c_plasma_hcd_secondary
                )
                * physics_variables.plasma_current
                / current_drive_variables.eta_cd_hcd_primary
            )

            # Calculate the driven current for the primary heating method
            current_drive_variables.c_hcd_primary_driven = (
                current_drive_variables.eta_cd_hcd_primary
                * current_drive_variables.p_hcd_primary_injected_mw
                * 1.0e6
            )
            # Calculate the fraction of the plasma current driven by the primary heating method
            current_drive_variables.f_c_plasma_hcd_primary = (
                current_drive_variables.c_hcd_primary_driven
                / physics_variables.plasma_current
            )

            # Calculate the dimensionless current drive efficiency for the primary heating method (ζ)
            current_drive_variables.eta_cd_dimensionless_hcd_primary = self.calculate_dimensionless_current_drive_efficiency(
                nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
                rmajor=physics_variables.rmajor,
                temp_plasma_electron_vol_avg_kev=physics_variables.temp_plasma_electron_vol_avg_kev,
                c_hcd_driven=current_drive_variables.c_hcd_primary_driven,
                p_hcd_injected=current_drive_variables.p_hcd_primary_injected_mw * 1.0e6,
            )

            if current_drive_variables.p_hcd_secondary_injected_mw > 0.0:
                # Calculate the dimensionless current drive efficiency for the secondary heating method (ζ)
                current_drive_variables.eta_cd_dimensionless_hcd_secondary = self.calculate_dimensionless_current_drive_efficiency(
                    nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
                    rmajor=physics_variables.rmajor,
                    temp_plasma_electron_vol_avg_kev=physics_variables.temp_plasma_electron_vol_avg_kev,
                    c_hcd_driven=current_drive_variables.c_hcd_secondary_driven,
                    p_hcd_injected=current_drive_variables.p_hcd_secondary_injected_mw
                    * 1.0e6,
                )

            # ===========================================================

            # Calculate the wall plug power for the secondary heating method
            # ==============================================================

            # Lower hybrid cases
            if current_drive_variables.i_hcd_secondary in [1, 4, 6]:
                # Injected power
                p_hcd_secondary_electrons_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_secondary_electric_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                ) / current_drive_variables.eta_lowhyb_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                    current_drive_variables.eta_lowhyb_injector_wall_plug
                )

                current_drive_variables.p_hcd_lowhyb_injected_total_mw += (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

            # ==========================================================

            # Ion cyclotron cases
            if current_drive_variables.i_hcd_secondary == 2:
                # Injected power
                p_hcd_secondary_ions_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_secondary_electric_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                ) / current_drive_variables.eta_icrh_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                    current_drive_variables.eta_icrh_injector_wall_plug
                )

                current_drive_variables.p_hcd_icrh_injected_total_mw += (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

            # ==========================================================

            # Electron cyclotron cases
            if current_drive_variables.i_hcd_secondary in [3, 7, 10, 13]:
                # Injected power
                p_hcd_secondary_electrons_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_secondary_electric_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                ) / current_drive_variables.eta_ecrh_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                    current_drive_variables.eta_ecrh_injector_wall_plug
                )

                current_drive_variables.p_hcd_ecrh_injected_total_mw += (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

            # ==========================================================

            # Electron berstein cases
            if current_drive_variables.i_hcd_secondary == 12:
                # Injected power
                p_hcd_secondary_electrons_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_secondary_electric_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                ) / current_drive_variables.eta_ebw_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                    current_drive_variables.eta_ebw_injector_wall_plug
                )

                current_drive_variables.p_hcd_ebw_injected_total_mw += (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

            # ==========================================================

            # Neutral beam cases
            elif current_drive_variables.i_hcd_secondary in [5, 8]:
                # Account for first orbit losses
                # (power due to particles that are ionised but not thermalised) [MW]:
                # This includes a second order term in shinethrough*(first orbit loss)

                current_drive_variables.f_p_beam_orbit_loss = min(
                    0.999, current_drive_variables.f_p_beam_orbit_loss
                )  # Should never be needed

                # Shinethrough power (atoms that are not ionised) [MW]:
                current_drive_variables.p_beam_shine_through_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                    * (1.0 - current_drive_variables.f_p_beam_shine_through)
                )

                # First orbit loss
                current_drive_variables.p_beam_orbit_loss_mw = (
                    current_drive_variables.f_p_beam_orbit_loss
                    * (
                        current_drive_variables.p_hcd_secondary_injected_mw
                        + current_drive_variables.p_hcd_secondary_extra_heat_mw
                        - current_drive_variables.p_beam_shine_through_mw
                    )
                )

                # Power deposited
                current_drive_variables.p_beam_plasma_coupled_mw = (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                    - current_drive_variables.p_beam_shine_through_mw
                    - current_drive_variables.p_beam_orbit_loss_mw
                )

                p_hcd_secondary_ions_mw = (
                    current_drive_variables.p_beam_plasma_coupled_mw
                    * current_drive_variables.f_p_beam_injected_ions
                )

                p_hcd_secondary_electrons_mw = (
                    current_drive_variables.p_beam_plasma_coupled_mw
                    * (1.0e0 - current_drive_variables.f_p_beam_injected_ions)
                )

                current_drive_variables.pwpnb = (
                    (
                        current_drive_variables.p_hcd_secondary_injected_mw
                        + current_drive_variables.p_hcd_secondary_extra_heat_mw
                    )
                    / current_drive_variables.eta_beam_injector_wall_plug
                )  # neutral beam wall plug power

                heat_transport_variables.p_hcd_secondary_electric_mw = (
                    current_drive_variables.pwpnb
                )

                current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                    current_drive_variables.eta_beam_injector_wall_plug
                )

                current_drive_variables.c_beam_total = (
                    1.0e-3
                    * (
                        (
                            current_drive_variables.p_hcd_secondary_injected_mw
                            + current_drive_variables.p_hcd_secondary_extra_heat_mw
                        )
                        * 1.0e6
                    )
                    / current_drive_variables.e_beam_kev
                )  # Neutral beam current (A)

                current_drive_variables.p_hcd_beam_injected_total_mw += (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )

            # ==========================================================

            # Lower hybrid cases
            if current_drive_variables.i_hcd_primary in [1, 4, 6]:
                p_hcd_primary_electrons_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                current_drive_variables.p_hcd_lowhyb_injected_total_mw += (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_primary_electric_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                ) / current_drive_variables.eta_lowhyb_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                    current_drive_variables.eta_lowhyb_injector_wall_plug
                )

                # Wall plug power
                current_drive_variables.p_hcd_lowhyb_electric_mw = (
                    current_drive_variables.p_hcd_lowhyb_injected_total_mw
                    / current_drive_variables.eta_lowhyb_injector_wall_plug
                )

            # ===========================================================

            # Ion cyclotron cases
            if current_drive_variables.i_hcd_primary == 2:
                p_hcd_primary_ions_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug power
                heat_transport_variables.p_hcd_primary_electric_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                ) / current_drive_variables.eta_icrh_injector_wall_plug

                # Wall plug to injector efficiency
                current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                    current_drive_variables.eta_icrh_injector_wall_plug
                )

                current_drive_variables.p_hcd_icrh_injected_total_mw += (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug power
                current_drive_variables.p_hcd_icrh_electric_mw = (
                    current_drive_variables.p_hcd_icrh_injected_total_mw
                    / current_drive_variables.eta_icrh_injector_wall_plug
                )

            # ===========================================================

            # Electron cyclotron cases

            if current_drive_variables.i_hcd_primary in [3, 7, 10, 13]:
                p_hcd_primary_electrons_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug to injector efficiency
                heat_transport_variables.p_hcd_primary_electric_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                ) / current_drive_variables.eta_ecrh_injector_wall_plug

                current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                    current_drive_variables.eta_ecrh_injector_wall_plug
                )

                current_drive_variables.p_hcd_ecrh_injected_total_mw += (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug power
                current_drive_variables.p_hcd_ecrh_electric_mw = (
                    current_drive_variables.p_hcd_ecrh_injected_total_mw
                    / current_drive_variables.eta_ecrh_injector_wall_plug
                )

            # ===========================================================

            # Electron bernstein cases

            if current_drive_variables.i_hcd_primary == 12:
                p_hcd_primary_electrons_mw = (
                    current_drive_variables.p_ebw_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug to injector efficiency
                heat_transport_variables.p_hcd_primary_electric_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                ) / current_drive_variables.eta_ebw_injector_wall_plug

                current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                    current_drive_variables.eta_ebw_injector_wall_plug
                )

                current_drive_variables.p_hcd_ebw_injected_total_mw += (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

                # Wall plug power
                current_drive_variables.p_hcd_ebw_electric_mw = (
                    current_drive_variables.p_ebw_injected_mw
                    / current_drive_variables.eta_ebw_injector_wall_plug
                )

            # ===========================================================

            elif current_drive_variables.i_hcd_primary in [5, 8]:
                # Account for first orbit losses
                # (power due to particles that are ionised but not thermalised) [MW]:
                # This includes a second order term in shinethrough*(first orbit loss)
                current_drive_variables.f_p_beam_orbit_loss = min(
                    0.999, current_drive_variables.f_p_beam_orbit_loss
                )  # Should never be needed

                # Shinethrough power (atoms that are not ionised) [MW]:
                current_drive_variables.p_beam_shine_through_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                    * (1.0 - current_drive_variables.f_p_beam_shine_through)
                )

                # First orbit loss
                current_drive_variables.p_beam_orbit_loss_mw = (
                    current_drive_variables.f_p_beam_orbit_loss
                    * (
                        current_drive_variables.p_hcd_primary_injected_mw
                        + current_drive_variables.p_hcd_primary_extra_heat_mw
                        - current_drive_variables.p_beam_shine_through_mw
                    )
                )

                # Power deposited
                current_drive_variables.p_beam_plasma_coupled_mw = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                    - current_drive_variables.p_beam_shine_through_mw
                    - current_drive_variables.p_beam_orbit_loss_mw
                )

                p_hcd_primary_ions_mw = (
                    pinjmw1 * current_drive_variables.f_p_beam_injected_ions
                )
                p_hcd_primary_electrons_mw = pinjmw1 * (
                    1.0e0 - current_drive_variables.f_p_beam_injected_ions
                )

                current_drive_variables.pwpnb = (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                    / current_drive_variables.eta_beam_injector_wall_plug
                )

                # Neutral beam wall plug power
                heat_transport_variables.p_hcd_primary_electric_mw = (
                    current_drive_variables.pwpnb
                )
                current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                    current_drive_variables.eta_beam_injector_wall_plug
                )

                current_drive_variables.c_beam_total = (
                    1.0e-3
                    * (
                        (
                            current_drive_variables.p_hcd_primary_injected_mw
                            + current_drive_variables.p_hcd_primary_extra_heat_mw
                        )
                        * 1.0e6
                    )
                    / current_drive_variables.e_beam_kev
                )  # Neutral beam current (A)

                current_drive_variables.p_hcd_beam_injected_total_mw += (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                )

            # ===========================================================

            # Total injected power that contributed to heating
            current_drive_variables.p_hcd_injected_total_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
                + current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

            # Total injected power that contributed to current drive
            current_drive_variables.p_hcd_injected_current_total_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_secondary_injected_mw
            )

            pinjmw1 = p_hcd_primary_electrons_mw + p_hcd_primary_ions_mw

            # Total injected power given to electrons
            current_drive_variables.p_hcd_injected_electrons_mw = (
                p_hcd_primary_electrons_mw + p_hcd_secondary_electrons_mw
            )

            # Total injected power given to ions
            current_drive_variables.p_hcd_injected_ions_mw = (
                p_hcd_primary_ions_mw + p_hcd_secondary_ions_mw
            )

            # Total wall plug power for all heating systems
            heat_transport_variables.p_hcd_electric_total_mw = (
                heat_transport_variables.p_hcd_primary_electric_mw
                + heat_transport_variables.p_hcd_secondary_electric_mw
            )

            # Reset injected power to zero for ignited plasma (fudge)
            if physics_variables.i_plasma_ignited == 1:
                heat_transport_variables.p_hcd_electric_total_mw = 0.0e0

            # Ratio of fusion to input (injection+ohmic) power
            current_drive_variables.big_q_plasma = (
                physics_variables.p_fusion_total_mw
                / (
                    current_drive_variables.p_hcd_injected_total_mw
                    + current_drive_variables.p_beam_orbit_loss_mw
                    + physics_variables.p_plasma_ohmic_mw
                )
            )

    def calculate_dimensionless_current_drive_efficiency(
        self,
        nd_plasma_electrons_vol_avg: float,
        rmajor: float,
        temp_plasma_electron_vol_avg_kev: float,
        c_hcd_driven: float,
        p_hcd_injected: float,
    ) -> float:
        """Calculate the dimensionless current drive efficiency, ζ.

        This function computes the dimensionless current drive efficiency
        based on the average electron density, major radius, and electron temperature.

        Parameters
        ----------
        nd_plasma_electrons_vol_avg:
            Volume averaged electron density in m^-3.
        rmajor:
            Major radius of the plasma in meters.
        temp_plasma_electron_vol_avg_kev:
            Volume averaged electron temperature in keV.
        c_hcd_driven:
            Current driven by the heating and current drive system.
        p_hcd_injected:
            Power injected by the heating and current drive system.

        Returns
        -------
        float
            The calculated dimensionless current drive efficiency.

        References
        ----------
        - E. Poli et al., “Electron-cyclotron-current-drive efficiency in DEMO plasmas,”
            Nuclear Fusion, vol. 53, no. 1, pp. 013011-013011, Dec. 2012,
            doi: https://doi.org/10.1088/0029-5515/53/1/013011.
        - T. C. Luce et al., “Generation of Localized Noninductive Current by Electron Cyclotron Waves on the DIII-D Tokamak,”
            Physical Review Letters, vol. 83, no. 22, pp. 4550-4553, Nov. 1999,
            doi: https://doi.org/10.1103/physrevlett.83.4550.
        """

        return (
            (constants.ELECTRON_CHARGE**3 / constants.EPSILON0**2)
            * (
                (nd_plasma_electrons_vol_avg * rmajor)
                / (temp_plasma_electron_vol_avg_kev * constants.KILOELECTRON_VOLT)
            )
            * (c_hcd_driven / p_hcd_injected)
        )

    def output_current_drive(self):
        """Output the current drive information to the output file.
        This method writes the current drive information to the output file.
        """

        po.oheadr(self.outfile, "Heating & Current Drive System")

        if physics_variables.i_plasma_ignited == 1:
            po.ocmmnt(
                self.outfile,
                "Ignited plasma; injected power only used for start-up phase",
            )

        if abs(physics_variables.f_c_plasma_inductive) > 1.0e-8:
            po.ocmmnt(
                self.outfile,
                "Current is driven by both inductive and non-inductive means.",
            )
            po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Fusion gain factor Q",
            "(big_q_plasma)",
            current_drive_variables.big_q_plasma,
            "OP ",
        )
        po.oblnkl(self.outfile)

        if current_drive_variables.i_hcd_calculations == 0:
            po.ocmmnt(self.outfile, "No current drive used")
            po.oblnkl(self.outfile)
            return

        po.ovarin(
            self.outfile,
            "Primary current drive efficiency model",
            "(i_hcd_primary)",
            current_drive_variables.i_hcd_primary,
        )

        if current_drive_variables.i_hcd_primary in [1, 4, 6]:
            po.ocmmnt(self.outfile, "Lower Hybrid Current Drive")
        elif current_drive_variables.i_hcd_primary == 2:
            po.ocmmnt(self.outfile, "Ion Cyclotron Current Drive")
        elif current_drive_variables.i_hcd_primary in [3, 7]:
            po.ocmmnt(self.outfile, "Electron Cyclotron Current Drive")
        elif current_drive_variables.i_hcd_primary in [5, 8]:
            po.ocmmnt(self.outfile, "Neutral Beam Current Drive")
        elif current_drive_variables.i_hcd_primary == 10:
            po.ocmmnt(
                self.outfile,
                "Electron Cyclotron Current Drive (input normalised efficiency)",
            )
        elif current_drive_variables.i_hcd_primary == 12:
            po.ocmmnt(self.outfile, "Electron Bernstein Wave Current Drive")
        elif current_drive_variables.i_hcd_primary == 13:
            po.ocmmnt(
                self.outfile,
                "Electron Cyclotron Current Drive (with Zeff & Te dependance)",
            )

        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Absolute current drive efficiency of primary system [A/W]",
            "(eta_cd_hcd_primary)",
            current_drive_variables.eta_cd_hcd_primary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Normalised current drive efficiency of primary system [10^20 A / Wm^2]",
            "(eta_cd_norm_hcd_primary)",
            current_drive_variables.eta_cd_norm_hcd_primary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Dimensionless current drive efficiency of primary system, ζ",
            "(eta_cd_dimensionless_hcd_primary)",
            current_drive_variables.eta_cd_dimensionless_hcd_primary,
            "OP ",
        )
        po.ovarre(
            self.mfile,
            "EBW coupling efficiency",
            "(xi_ebw)",
            current_drive_variables.xi_ebw,
        )
        if current_drive_variables.i_hcd_primary == 10:
            po.ovarre(
                self.outfile,
                "ECRH plasma heating efficiency",
                "(eta_cd_norm_ecrh)",
                current_drive_variables.eta_cd_norm_ecrh,
            )
        po.ovarre(
            self.outfile,
            "Power injected into plasma by primary system for current drive (MW)",
            "(p_hcd_primary_injected_mw)",
            current_drive_variables.p_hcd_primary_injected_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Extra power injected into plasma by primary system  (MW)",
            "(p_hcd_primary_extra_heat_mw)",
            current_drive_variables.p_hcd_primary_extra_heat_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Current driven in plasma by primary system (A)",
            "(c_hcd_primary_driven)",
            current_drive_variables.c_hcd_primary_driven,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Fraction of plasma current driven by primary system",
            "(f_c_plasma_hcd_primary)",
            current_drive_variables.f_c_plasma_hcd_primary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Wall plug to injector efficiency of primary system",
            "(eta_hcd_primary_injector_wall_plug)",
            current_drive_variables.eta_hcd_primary_injector_wall_plug,
            "IP ",
        )
        po.ovarre(
            self.outfile,
            "Wall plug electric power of primary system",
            "(p_hcd_primary_electric_mw)",
            heat_transport_variables.p_hcd_primary_electric_mw,
            "OP ",
        )

        if current_drive_variables.i_hcd_primary in [12, 13]:
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "ECRH / EBW harmonic number",
                "(n_ecrh_harmonic)",
                current_drive_variables.n_ecrh_harmonic,
            )
            po.ovarre(
                self.outfile,
                "EBW coupling efficiency",
                "(xi_ebw)",
                current_drive_variables.xi_ebw,
            )
        if current_drive_variables.i_hcd_primary == 13:
            po.ovarin(
                self.outfile,
                "Electron cyclotron cutoff wave mode switch",
                "(i_ecrh_wave_mode)",
                current_drive_variables.i_ecrh_wave_mode,
            )

        po.oblnkl(self.outfile)

        if current_drive_variables.i_hcd_primary in [5, 8]:
            po.oblnkl(self.outfile)
            po.ocmmnt(self.outfile, "Neutral beam power balance :")
            po.ocmmnt(self.outfile, "----------------------------")

            po.ovarre(
                self.outfile,
                "Neutral beam energy (keV)",
                "(e_beam_kev)",
                current_drive_variables.e_beam_kev,
            )
            if (current_drive_variables.i_hcd_primary == 5) or (
                current_drive_variables.i_hcd_primary == 8
            ):
                po.ovarre(
                    self.outfile,
                    "Neutral beam current (A)",
                    "(c_beam_total)",
                    current_drive_variables.c_beam_total,
                    "OP ",
                )

            po.ovarre(
                self.outfile,
                "Neutral beam wall plug efficiency",
                "(eta_beam_injector_wall_plug)",
                current_drive_variables.eta_beam_injector_wall_plug,
            )
            po.ovarre(
                self.outfile,
                "Beam decay lengths to centre",
                "(n_beam_decay_lengths_core)",
                current_drive_variables.n_beam_decay_lengths_core,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Beam shine-through fraction",
                "(f_p_beam_shine_through)",
                current_drive_variables.f_p_beam_shine_through,
                "OP ",
            )

            if (current_drive_variables.i_hcd_primary == 5) or (
                current_drive_variables.i_hcd_primary == 8
            ):
                po.ovarrf(
                    self.outfile,
                    "Beam first orbit loss power (MW)",
                    "(p_beam_orbit_loss_mw)",
                    current_drive_variables.p_beam_orbit_loss_mw,
                    "OP ",
                )
                po.ovarrf(
                    self.outfile,
                    "Beam shine-through power [MW]",
                    "(p_beam_shine_through_mw)",
                    current_drive_variables.p_beam_shine_through_mw,
                    "OP ",
                )
                po.ovarrf(
                    self.outfile,
                    "Maximum allowable beam power (MW)",
                    "(p_hcd_injected_max)",
                    current_drive_variables.p_hcd_injected_max,
                )
                po.oblnkl(self.outfile)
                po.ovarrf(
                    self.outfile,
                    "Beam power entering vacuum vessel (MW)",
                    "(p_beam_injected_mw)",
                    current_drive_variables.p_beam_injected_mw,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Fraction of beam energy to ions",
                    "(f_p_beam_injected_ions)",
                    current_drive_variables.f_p_beam_injected_ions,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Beam duct shielding thickness (m)",
                    "(dx_beam_shield)",
                    current_drive_variables.dx_beam_shield,
                )
                po.ovarre(
                    self.outfile,
                    "Beam tangency radius / Plasma major radius",
                    "(f_radius_beam_tangency_rmajor)",
                    current_drive_variables.f_radius_beam_tangency_rmajor,
                )
                po.ovarre(
                    self.outfile,
                    "Beam centreline tangency radius (m)",
                    "(radius_beam_tangency)",
                    current_drive_variables.radius_beam_tangency,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Maximum possible tangency radius (m)",
                    "(radius_beam_tangency_max)",
                    current_drive_variables.radius_beam_tangency_max,
                    "OP ",
                )

        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)
        po.ovarin(
            self.outfile,
            "Secondary current drive efficiency model",
            "(i_hcd_secondary)",
            current_drive_variables.i_hcd_secondary,
        )

        if current_drive_variables.i_hcd_secondary in [1, 4, 6]:
            po.ocmmnt(self.outfile, "Lower Hybrid Current Drive")
        elif current_drive_variables.i_hcd_secondary == 2:
            po.ocmmnt(self.outfile, "Ion Cyclotron Current Drive")
        elif current_drive_variables.i_hcd_secondary in [3, 7]:
            po.ocmmnt(self.outfile, "Electron Cyclotron Current Drive")
        elif current_drive_variables.i_hcd_secondary in [5, 8]:
            po.ocmmnt(self.outfile, "Neutral Beam Current Drive")
        elif current_drive_variables.i_hcd_secondary == 10:
            po.ocmmnt(
                self.outfile,
                "Electron Cyclotron Current Drive (input normalised efficiency)",
            )
        elif current_drive_variables.i_hcd_secondary == 12:
            po.ocmmnt(self.outfile, "Electron Bernstein Wave Current Drive")
        elif current_drive_variables.i_hcd_secondary == 13:
            po.ocmmnt(
                self.outfile,
                "Electron Cyclotron Current Drive (with Zeff & Te dependance)",
            )
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Absolute current drive efficiency of secondary system [A/W]",
            "(eta_cd_hcd_secondary)",
            current_drive_variables.eta_cd_hcd_secondary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Normalised current drive efficiency of secondary system [10^20 A / Wm^2]",
            "(eta_cd_norm_hcd_secondary)",
            current_drive_variables.eta_cd_norm_hcd_secondary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Dimensionless current drive efficiency of secondary system, ζ",
            "(eta_cd_dimensionless_hcd_secondary)",
            current_drive_variables.eta_cd_dimensionless_hcd_secondary,
            "OP ",
        )
        if current_drive_variables.i_hcd_secondary == 10:
            po.ovarre(
                self.outfile,
                "ECRH plasma heating efficiency",
                "(eta_cd_norm_ecrh)",
                current_drive_variables.eta_cd_norm_ecrh,
            )

        po.ovarre(
            self.outfile,
            "Power injected into plasma by secondary system (MW)",
            "(p_hcd_secondary_injected_mw)",
            current_drive_variables.p_hcd_secondary_injected_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Extra power injected into plasma by secondary system  (MW)",
            "(p_hcd_secondary_extra_heat_mw)",
            current_drive_variables.p_hcd_secondary_extra_heat_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Current driven in plasma by secondary system (A)",
            "(c_hcd_secondary_driven)",
            current_drive_variables.c_hcd_secondary_driven,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Fraction of plasma current driven by secondary system",
            "(f_c_plasma_hcd_secondary)",
            current_drive_variables.f_c_plasma_hcd_secondary,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Wall plug to injector efficiency of secondary system",
            "(eta_hcd_secondary_injector_wall_plug)",
            current_drive_variables.eta_hcd_secondary_injector_wall_plug,
            "IP ",
        )
        po.ovarre(
            self.outfile,
            "Wall plug electric power of secondary system",
            "(p_hcd_secondary_electric_mw)",
            heat_transport_variables.p_hcd_secondary_electric_mw,
            "OP ",
        )

        po.oblnkl(self.outfile)

        if current_drive_variables.i_hcd_secondary in [5, 8]:
            po.oblnkl(self.outfile)
            po.ocmmnt(self.outfile, "Neutral beam power balance :")
            po.ocmmnt(self.outfile, "----------------------------")

            po.ovarre(
                self.outfile,
                "Neutral beam energy (keV)",
                "(e_beam_kev)",
                current_drive_variables.e_beam_kev,
            )
            if (current_drive_variables.i_hcd_primary == 5) or (
                current_drive_variables.i_hcd_primary == 8
            ):
                po.ovarre(
                    self.outfile,
                    "Neutral beam current (A)",
                    "(c_beam_total)",
                    current_drive_variables.c_beam_total,
                    "OP ",
                )

            po.ovarre(
                self.outfile,
                "Neutral beam wall plug efficiency",
                "(eta_beam_injector_wall_plug)",
                current_drive_variables.eta_beam_injector_wall_plug,
            )
            po.ovarre(
                self.outfile,
                "Beam decay lengths to centre",
                "(n_beam_decay_lengths_core)",
                current_drive_variables.n_beam_decay_lengths_core,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Beam shine-through fraction",
                "(f_p_beam_shine_through)",
                current_drive_variables.f_p_beam_shine_through,
                "OP ",
            )

            if (current_drive_variables.i_hcd_primary == 5) or (
                current_drive_variables.i_hcd_primary == 8
            ):
                po.ovarrf(
                    self.outfile,
                    "Beam first orbit loss power (MW)",
                    "(p_beam_orbit_loss_mw)",
                    current_drive_variables.p_beam_orbit_loss_mw,
                    "OP ",
                )
                po.ovarrf(
                    self.outfile,
                    "Beam shine-through power [MW]",
                    "(p_beam_shine_through_mw)",
                    current_drive_variables.p_beam_shine_through_mw,
                    "OP ",
                )
                po.ovarrf(
                    self.outfile,
                    "Maximum allowable beam power (MW)",
                    "(p_hcd_injected_max)",
                    current_drive_variables.p_hcd_injected_max,
                )
                po.oblnkl(self.outfile)
                po.ovarrf(
                    self.outfile,
                    "Beam power entering vacuum vessel (MW)",
                    "(p_beam_injected_mw)",
                    current_drive_variables.p_beam_injected_mw,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Fraction of beam energy to ions",
                    "(f_p_beam_injected_ions)",
                    current_drive_variables.f_p_beam_injected_ions,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Beam duct shielding thickness (m)",
                    "(dx_beam_shield)",
                    current_drive_variables.dx_beam_shield,
                )
                po.ovarre(
                    self.outfile,
                    "Beam tangency radius / Plasma major radius",
                    "(f_radius_beam_tangency_rmajor)",
                    current_drive_variables.f_radius_beam_tangency_rmajor,
                )
                po.ovarre(
                    self.outfile,
                    "Beam centreline tangency radius (m)",
                    "(radius_beam_tangency)",
                    current_drive_variables.radius_beam_tangency,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Maximum possible tangency radius (m)",
                    "(radius_beam_tangency_max)",
                    current_drive_variables.radius_beam_tangency_max,
                    "OP ",
                )

        po.ocmmnt(self.outfile, "----------------------------")

        po.osubhd(self.outfile, "Totals :")

        po.ovarre(
            self.outfile,
            "Total injected heating power that drove plasma current (MW)",
            "(p_hcd_injected_current_total_mw)",
            current_drive_variables.p_hcd_injected_current_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Total injected heating power across all systems (MW)",
            "(p_hcd_injected_total_mw)",
            current_drive_variables.p_hcd_injected_total_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total injected heating power given to the electrons (MW)",
            "(p_hcd_injected_electrons_mw)",
            current_drive_variables.p_hcd_injected_electrons_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total injected heating power given to the ions (MW)",
            "(p_hcd_injected_ions_mw)",
            current_drive_variables.p_hcd_injected_ions_mw,
            "OP ",
        )

        po.ovarre(
            self.outfile,
            "Upper limit on total plasma injected power (MW)",
            "(p_hcd_injected_max)",
            current_drive_variables.p_hcd_injected_max,
            "OP ",
        )

        po.osubhd(self.outfile, "Contributions:")

        po.ovarre(
            self.outfile,
            "Injected power into plasma from lower hybrid systems (MW)",
            "(p_hcd_lowhyb_injected_total_mw)",
            current_drive_variables.p_hcd_lowhyb_injected_total_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Injected power into plasma from ion cyclotron systems (MW)",
            "(p_hcd_icrh_injected_total_mw)",
            current_drive_variables.p_hcd_icrh_injected_total_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Injected power into plasma from electron cyclotron systems (MW)",
            "(p_hcd_ecrh_injected_total_mw)",
            current_drive_variables.p_hcd_ecrh_injected_total_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Injected power into plasma from neutral beam systems (MW)",
            "(p_hcd_beam_injected_total_mw)",
            current_drive_variables.p_hcd_beam_injected_total_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Injected power into plasma from lower hybrid systems (MW)",
            "(p_hcd_ebw_injected_total_mw)",
            current_drive_variables.p_hcd_ebw_injected_total_mw,
            "OP ",
        )

        po.osubhd(self.outfile, "Fractions of current drive :")
        po.ovarrf(
            self.outfile,
            "Bootstrap fraction",
            "(f_c_plasma_bootstrap)",
            current_drive_variables.f_c_plasma_bootstrap,
            "OP ",
        )
        po.ovarrf(
            self.outfile,
            "Diamagnetic fraction",
            "(f_c_plasma_diamagnetic)",
            current_drive_variables.f_c_plasma_diamagnetic,
            "OP ",
        )
        po.ovarrf(
            self.outfile,
            "Pfirsch-Schlueter fraction",
            "(f_c_plasma_pfirsch_schluter)",
            current_drive_variables.f_c_plasma_pfirsch_schluter,
            "OP ",
        )
        po.ovarrf(
            self.outfile,
            "Auxiliary current drive fraction",
            "(f_c_plasma_auxiliary)",
            physics_variables.f_c_plasma_auxiliary,
            "OP ",
        )
        po.ovarrf(
            self.outfile,
            "Inductive fraction",
            "(f_c_plasma_inductive)",
            physics_variables.f_c_plasma_inductive,
            "OP ",
        )

        # MDK Add physics_variables.f_c_plasma_non_inductive as it can be an iteration variable
        po.ovarrf(
            self.outfile,
            "Fraction of the plasma current produced by non-inductive means",
            "(f_c_plasma_non_inductive)",
            physics_variables.f_c_plasma_non_inductive,
        )

        if (
            abs(
                current_drive_variables.f_c_plasma_bootstrap
                - current_drive_variables.f_c_plasma_bootstrap_max
            )
            < 1.0e-8
        ):
            po.ocmmnt(self.outfile, "Warning : bootstrap current fraction is at")
            po.ocmmnt(self.outfile, "          its prescribed maximum.")

        po.oblnkl(self.outfile)

outfile = constants.NOUT instance-attribute

mfile = constants.MFILE instance-attribute

plasma_profile = plasma_profile instance-attribute

electron_cyclotron = electron_cyclotron instance-attribute

ion_cyclotron = ion_cyclotron instance-attribute

lower_hybrid = lower_hybrid instance-attribute

neutral_beam = neutral_beam instance-attribute

electron_bernstein = electron_bernstein instance-attribute

cudriv()

Calculate the current drive power requirements.

This method computes the power requirements of the current drive system using a choice of models for the current drive efficiency.

Parameters:

Name Type Description Default
output

Flag indicating whether to write results to the output file.

required

Raises:

Type Description
ProcessValueError

If an invalid current drive switch is encountered.

Source code in process/models/physics/current_drive.py
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
def cudriv(self):
    """Calculate the current drive power requirements.

    This method computes the power requirements of the current drive system
    using a choice of models for the current drive efficiency.

    Parameters
    ----------
    output: bool
        Flag indicating whether to write results to the output file.

    Raises
    ------
    ProcessValueError
        If an invalid current drive switch is encountered.
    """

    current_drive_variables.p_hcd_ecrh_injected_total_mw = 0.0e0
    current_drive_variables.p_hcd_beam_injected_total_mw = 0.0e0
    current_drive_variables.p_hcd_lowhyb_injected_total_mw = 0.0e0
    current_drive_variables.p_hcd_icrh_injected_total_mw = 0.0e0
    current_drive_variables.p_hcd_ebw_injected_total_mw = 0.0e0
    current_drive_variables.c_beam_total = 0.0e0
    current_drive_variables.p_beam_orbit_loss_mw = 0.0e0

    pinjmw1 = 0.0
    p_hcd_primary_ions_mw = 0.0
    p_hcd_primary_electrons_mw = 0.0
    p_hcd_secondary_electrons_mw = 0.0
    p_hcd_secondary_ions_mw = 0.0

    # To stop issues with input file we force
    # zero secondary heating if no injection method
    if current_drive_variables.i_hcd_secondary == 0:
        current_drive_variables.p_hcd_secondary_extra_heat_mw = 0.0

    # i_hcd_calculations |  switch for current drive calculation
    # = 0   |  turned off
    # = 1   |  turned on

    if current_drive_variables.i_hcd_calculations != 0:
        # Put electron density in desired units (10^-20 m-3)
        dene20 = physics_variables.nd_plasma_electrons_vol_avg * 1.0e-20

        # Calculate current drive efficiencies
        # ==============================================================

        # Define a dictionary of lambda functions for current drive efficiency models
        hcd_models = {
            1: lambda: (
                self.lower_hybrid.lower_hybrid_fenstermacher(
                    physics_variables.temp_plasma_electron_vol_avg_kev,
                    physics_variables.rmajor,
                    dene20,
                )
                * current_drive_variables.feffcd
            ),
            2: lambda: (
                self.ion_cyclotron.ion_cyclotron_ipdg89(
                    temp_plasma_electron_density_weighted_kev=physics_variables.temp_plasma_electron_density_weighted_kev,
                    zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                    rmajor=physics_variables.rmajor,
                    dene20=dene20,
                )
                * current_drive_variables.feffcd
            ),
            3: lambda: (
                self.electron_cyclotron.electron_cyclotron_fenstermacher(
                    temp_plasma_electron_density_weighted_kev=physics_variables.temp_plasma_electron_density_weighted_kev,
                    rmajor=physics_variables.rmajor,
                    dene20=dene20,
                    dlamee=physics_variables.dlamee,
                )
                * current_drive_variables.feffcd
            ),
            4: lambda: (
                self.lower_hybrid.lower_hybrid_ehst(
                    te=physics_variables.temp_plasma_electron_vol_avg_kev,
                    beta=physics_variables.beta_total_vol_avg,
                    rmajor=physics_variables.rmajor,
                    dene20=dene20,
                    zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                )
                * current_drive_variables.feffcd
            ),
            5: lambda: (
                self.neutral_beam.iternb()[0] * current_drive_variables.feffcd
            ),
            6: lambda: self.lower_hybrid.cullhy() * current_drive_variables.feffcd,
            7: lambda: (
                self.electron_cyclotron.culecd() * current_drive_variables.feffcd
            ),
            8: lambda: (
                self.neutral_beam.culnbi()[0] * current_drive_variables.feffcd
            ),
            10: lambda: (
                current_drive_variables.eta_cd_norm_ecrh
                / (dene20 * physics_variables.rmajor)
            ),
            12: lambda: (
                self.electron_bernstein.electron_bernstein_freethy(
                    te=physics_variables.temp_plasma_electron_vol_avg_kev,
                    rmajor=physics_variables.rmajor,
                    dene20=dene20,
                    b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
                    n_ecrh_harmonic=current_drive_variables.n_ecrh_harmonic,
                    xi_ebw=current_drive_variables.xi_ebw,
                )
                * current_drive_variables.feffcd
            ),
            13: lambda: (
                self.electron_cyclotron.electron_cyclotron_freethy(
                    te=physics_variables.temp_plasma_electron_vol_avg_kev,
                    zeff=physics_variables.n_charge_plasma_effective_vol_avg,
                    rmajor=physics_variables.rmajor,
                    nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
                    b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
                    n_ecrh_harmonic=current_drive_variables.n_ecrh_harmonic,
                    i_ecrh_wave_mode=current_drive_variables.i_ecrh_wave_mode,
                )
                * current_drive_variables.feffcd
            ),
        }

        # Assign outputs for models that return multiple values
        if current_drive_variables.i_hcd_secondary in [5, 8]:
            _, f_p_beam_injected_ions, f_p_beam_shine_through = (
                self.neutral_beam.iternb()
                if current_drive_variables.i_hcd_secondary == 5
                else self.neutral_beam.culnbi()
            )
            current_drive_variables.f_p_beam_injected_ions = f_p_beam_injected_ions
            current_drive_variables.f_p_beam_shine_through = f_p_beam_shine_through

        # Calculate eta_cd_hcd_secondary based on the selected model
        if current_drive_variables.i_hcd_secondary in hcd_models:
            current_drive_variables.eta_cd_hcd_secondary = hcd_models[
                current_drive_variables.i_hcd_secondary
            ]()
        elif current_drive_variables.i_hcd_secondary != 0:
            raise ProcessValueError(
                f"Current drive switch is invalid: {current_drive_variables.i_hcd_secondary = }"
            )

        # Calculate eta_cd_hcd_primary based on the selected model
        if current_drive_variables.i_hcd_primary in hcd_models:
            current_drive_variables.eta_cd_hcd_primary = hcd_models[
                current_drive_variables.i_hcd_primary
            ]()
        else:
            raise ProcessValueError(
                f"Current drive switch is invalid: {current_drive_variables.i_hcd_primary = }"
            )

        # Calculate the normalised current drive efficieny for the primary heating method
        current_drive_variables.eta_cd_norm_hcd_primary = (
            current_drive_variables.eta_cd_hcd_primary
            * (dene20 * physics_variables.rmajor)
        )
        # Calculate the normalised current drive efficieny for the secondary heating method
        current_drive_variables.eta_cd_norm_hcd_secondary = (
            current_drive_variables.eta_cd_hcd_secondary
            * (dene20 * physics_variables.rmajor)
        )

        # Calculate the driven current for the secondary heating method
        current_drive_variables.c_hcd_secondary_driven = (
            current_drive_variables.eta_cd_hcd_secondary
            * current_drive_variables.p_hcd_secondary_injected_mw
            * 1.0e6
        )
        # Calculate the fraction of the plasma current driven by the secondary heating method
        current_drive_variables.f_c_plasma_hcd_secondary = (
            current_drive_variables.c_hcd_secondary_driven
            / physics_variables.plasma_current
        )

        # Calculate the injected power for the primary heating method
        current_drive_variables.p_hcd_primary_injected_mw = (
            1.0e-6
            * (
                physics_variables.f_c_plasma_auxiliary
                - current_drive_variables.f_c_plasma_hcd_secondary
            )
            * physics_variables.plasma_current
            / current_drive_variables.eta_cd_hcd_primary
        )

        # Calculate the driven current for the primary heating method
        current_drive_variables.c_hcd_primary_driven = (
            current_drive_variables.eta_cd_hcd_primary
            * current_drive_variables.p_hcd_primary_injected_mw
            * 1.0e6
        )
        # Calculate the fraction of the plasma current driven by the primary heating method
        current_drive_variables.f_c_plasma_hcd_primary = (
            current_drive_variables.c_hcd_primary_driven
            / physics_variables.plasma_current
        )

        # Calculate the dimensionless current drive efficiency for the primary heating method (ζ)
        current_drive_variables.eta_cd_dimensionless_hcd_primary = self.calculate_dimensionless_current_drive_efficiency(
            nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
            rmajor=physics_variables.rmajor,
            temp_plasma_electron_vol_avg_kev=physics_variables.temp_plasma_electron_vol_avg_kev,
            c_hcd_driven=current_drive_variables.c_hcd_primary_driven,
            p_hcd_injected=current_drive_variables.p_hcd_primary_injected_mw * 1.0e6,
        )

        if current_drive_variables.p_hcd_secondary_injected_mw > 0.0:
            # Calculate the dimensionless current drive efficiency for the secondary heating method (ζ)
            current_drive_variables.eta_cd_dimensionless_hcd_secondary = self.calculate_dimensionless_current_drive_efficiency(
                nd_plasma_electrons_vol_avg=physics_variables.nd_plasma_electrons_vol_avg,
                rmajor=physics_variables.rmajor,
                temp_plasma_electron_vol_avg_kev=physics_variables.temp_plasma_electron_vol_avg_kev,
                c_hcd_driven=current_drive_variables.c_hcd_secondary_driven,
                p_hcd_injected=current_drive_variables.p_hcd_secondary_injected_mw
                * 1.0e6,
            )

        # ===========================================================

        # Calculate the wall plug power for the secondary heating method
        # ==============================================================

        # Lower hybrid cases
        if current_drive_variables.i_hcd_secondary in [1, 4, 6]:
            # Injected power
            p_hcd_secondary_electrons_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_secondary_electric_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            ) / current_drive_variables.eta_lowhyb_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                current_drive_variables.eta_lowhyb_injector_wall_plug
            )

            current_drive_variables.p_hcd_lowhyb_injected_total_mw += (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

        # ==========================================================

        # Ion cyclotron cases
        if current_drive_variables.i_hcd_secondary == 2:
            # Injected power
            p_hcd_secondary_ions_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_secondary_electric_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            ) / current_drive_variables.eta_icrh_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                current_drive_variables.eta_icrh_injector_wall_plug
            )

            current_drive_variables.p_hcd_icrh_injected_total_mw += (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

        # ==========================================================

        # Electron cyclotron cases
        if current_drive_variables.i_hcd_secondary in [3, 7, 10, 13]:
            # Injected power
            p_hcd_secondary_electrons_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_secondary_electric_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            ) / current_drive_variables.eta_ecrh_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                current_drive_variables.eta_ecrh_injector_wall_plug
            )

            current_drive_variables.p_hcd_ecrh_injected_total_mw += (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

        # ==========================================================

        # Electron berstein cases
        if current_drive_variables.i_hcd_secondary == 12:
            # Injected power
            p_hcd_secondary_electrons_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_secondary_electric_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            ) / current_drive_variables.eta_ebw_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                current_drive_variables.eta_ebw_injector_wall_plug
            )

            current_drive_variables.p_hcd_ebw_injected_total_mw += (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

        # ==========================================================

        # Neutral beam cases
        elif current_drive_variables.i_hcd_secondary in [5, 8]:
            # Account for first orbit losses
            # (power due to particles that are ionised but not thermalised) [MW]:
            # This includes a second order term in shinethrough*(first orbit loss)

            current_drive_variables.f_p_beam_orbit_loss = min(
                0.999, current_drive_variables.f_p_beam_orbit_loss
            )  # Should never be needed

            # Shinethrough power (atoms that are not ionised) [MW]:
            current_drive_variables.p_beam_shine_through_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
                * (1.0 - current_drive_variables.f_p_beam_shine_through)
            )

            # First orbit loss
            current_drive_variables.p_beam_orbit_loss_mw = (
                current_drive_variables.f_p_beam_orbit_loss
                * (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                    - current_drive_variables.p_beam_shine_through_mw
                )
            )

            # Power deposited
            current_drive_variables.p_beam_plasma_coupled_mw = (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
                - current_drive_variables.p_beam_shine_through_mw
                - current_drive_variables.p_beam_orbit_loss_mw
            )

            p_hcd_secondary_ions_mw = (
                current_drive_variables.p_beam_plasma_coupled_mw
                * current_drive_variables.f_p_beam_injected_ions
            )

            p_hcd_secondary_electrons_mw = (
                current_drive_variables.p_beam_plasma_coupled_mw
                * (1.0e0 - current_drive_variables.f_p_beam_injected_ions)
            )

            current_drive_variables.pwpnb = (
                (
                    current_drive_variables.p_hcd_secondary_injected_mw
                    + current_drive_variables.p_hcd_secondary_extra_heat_mw
                )
                / current_drive_variables.eta_beam_injector_wall_plug
            )  # neutral beam wall plug power

            heat_transport_variables.p_hcd_secondary_electric_mw = (
                current_drive_variables.pwpnb
            )

            current_drive_variables.eta_hcd_secondary_injector_wall_plug = (
                current_drive_variables.eta_beam_injector_wall_plug
            )

            current_drive_variables.c_beam_total = (
                1.0e-3
                * (
                    (
                        current_drive_variables.p_hcd_secondary_injected_mw
                        + current_drive_variables.p_hcd_secondary_extra_heat_mw
                    )
                    * 1.0e6
                )
                / current_drive_variables.e_beam_kev
            )  # Neutral beam current (A)

            current_drive_variables.p_hcd_beam_injected_total_mw += (
                current_drive_variables.p_hcd_secondary_injected_mw
                + current_drive_variables.p_hcd_secondary_extra_heat_mw
            )

        # ==========================================================

        # Lower hybrid cases
        if current_drive_variables.i_hcd_primary in [1, 4, 6]:
            p_hcd_primary_electrons_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            current_drive_variables.p_hcd_lowhyb_injected_total_mw += (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_primary_electric_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            ) / current_drive_variables.eta_lowhyb_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                current_drive_variables.eta_lowhyb_injector_wall_plug
            )

            # Wall plug power
            current_drive_variables.p_hcd_lowhyb_electric_mw = (
                current_drive_variables.p_hcd_lowhyb_injected_total_mw
                / current_drive_variables.eta_lowhyb_injector_wall_plug
            )

        # ===========================================================

        # Ion cyclotron cases
        if current_drive_variables.i_hcd_primary == 2:
            p_hcd_primary_ions_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug power
            heat_transport_variables.p_hcd_primary_electric_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            ) / current_drive_variables.eta_icrh_injector_wall_plug

            # Wall plug to injector efficiency
            current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                current_drive_variables.eta_icrh_injector_wall_plug
            )

            current_drive_variables.p_hcd_icrh_injected_total_mw += (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug power
            current_drive_variables.p_hcd_icrh_electric_mw = (
                current_drive_variables.p_hcd_icrh_injected_total_mw
                / current_drive_variables.eta_icrh_injector_wall_plug
            )

        # ===========================================================

        # Electron cyclotron cases

        if current_drive_variables.i_hcd_primary in [3, 7, 10, 13]:
            p_hcd_primary_electrons_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug to injector efficiency
            heat_transport_variables.p_hcd_primary_electric_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            ) / current_drive_variables.eta_ecrh_injector_wall_plug

            current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                current_drive_variables.eta_ecrh_injector_wall_plug
            )

            current_drive_variables.p_hcd_ecrh_injected_total_mw += (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug power
            current_drive_variables.p_hcd_ecrh_electric_mw = (
                current_drive_variables.p_hcd_ecrh_injected_total_mw
                / current_drive_variables.eta_ecrh_injector_wall_plug
            )

        # ===========================================================

        # Electron bernstein cases

        if current_drive_variables.i_hcd_primary == 12:
            p_hcd_primary_electrons_mw = (
                current_drive_variables.p_ebw_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug to injector efficiency
            heat_transport_variables.p_hcd_primary_electric_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            ) / current_drive_variables.eta_ebw_injector_wall_plug

            current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                current_drive_variables.eta_ebw_injector_wall_plug
            )

            current_drive_variables.p_hcd_ebw_injected_total_mw += (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

            # Wall plug power
            current_drive_variables.p_hcd_ebw_electric_mw = (
                current_drive_variables.p_ebw_injected_mw
                / current_drive_variables.eta_ebw_injector_wall_plug
            )

        # ===========================================================

        elif current_drive_variables.i_hcd_primary in [5, 8]:
            # Account for first orbit losses
            # (power due to particles that are ionised but not thermalised) [MW]:
            # This includes a second order term in shinethrough*(first orbit loss)
            current_drive_variables.f_p_beam_orbit_loss = min(
                0.999, current_drive_variables.f_p_beam_orbit_loss
            )  # Should never be needed

            # Shinethrough power (atoms that are not ionised) [MW]:
            current_drive_variables.p_beam_shine_through_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
                * (1.0 - current_drive_variables.f_p_beam_shine_through)
            )

            # First orbit loss
            current_drive_variables.p_beam_orbit_loss_mw = (
                current_drive_variables.f_p_beam_orbit_loss
                * (
                    current_drive_variables.p_hcd_primary_injected_mw
                    + current_drive_variables.p_hcd_primary_extra_heat_mw
                    - current_drive_variables.p_beam_shine_through_mw
                )
            )

            # Power deposited
            current_drive_variables.p_beam_plasma_coupled_mw = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
                - current_drive_variables.p_beam_shine_through_mw
                - current_drive_variables.p_beam_orbit_loss_mw
            )

            p_hcd_primary_ions_mw = (
                pinjmw1 * current_drive_variables.f_p_beam_injected_ions
            )
            p_hcd_primary_electrons_mw = pinjmw1 * (
                1.0e0 - current_drive_variables.f_p_beam_injected_ions
            )

            current_drive_variables.pwpnb = (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
                / current_drive_variables.eta_beam_injector_wall_plug
            )

            # Neutral beam wall plug power
            heat_transport_variables.p_hcd_primary_electric_mw = (
                current_drive_variables.pwpnb
            )
            current_drive_variables.eta_hcd_primary_injector_wall_plug = (
                current_drive_variables.eta_beam_injector_wall_plug
            )

            current_drive_variables.c_beam_total = (
                1.0e-3
                * (
                    (
                        current_drive_variables.p_hcd_primary_injected_mw
                        + current_drive_variables.p_hcd_primary_extra_heat_mw
                    )
                    * 1.0e6
                )
                / current_drive_variables.e_beam_kev
            )  # Neutral beam current (A)

            current_drive_variables.p_hcd_beam_injected_total_mw += (
                current_drive_variables.p_hcd_primary_injected_mw
                + current_drive_variables.p_hcd_primary_extra_heat_mw
            )

        # ===========================================================

        # Total injected power that contributed to heating
        current_drive_variables.p_hcd_injected_total_mw = (
            current_drive_variables.p_hcd_primary_injected_mw
            + current_drive_variables.p_hcd_primary_extra_heat_mw
            + current_drive_variables.p_hcd_secondary_injected_mw
            + current_drive_variables.p_hcd_secondary_extra_heat_mw
        )

        # Total injected power that contributed to current drive
        current_drive_variables.p_hcd_injected_current_total_mw = (
            current_drive_variables.p_hcd_primary_injected_mw
            + current_drive_variables.p_hcd_secondary_injected_mw
        )

        pinjmw1 = p_hcd_primary_electrons_mw + p_hcd_primary_ions_mw

        # Total injected power given to electrons
        current_drive_variables.p_hcd_injected_electrons_mw = (
            p_hcd_primary_electrons_mw + p_hcd_secondary_electrons_mw
        )

        # Total injected power given to ions
        current_drive_variables.p_hcd_injected_ions_mw = (
            p_hcd_primary_ions_mw + p_hcd_secondary_ions_mw
        )

        # Total wall plug power for all heating systems
        heat_transport_variables.p_hcd_electric_total_mw = (
            heat_transport_variables.p_hcd_primary_electric_mw
            + heat_transport_variables.p_hcd_secondary_electric_mw
        )

        # Reset injected power to zero for ignited plasma (fudge)
        if physics_variables.i_plasma_ignited == 1:
            heat_transport_variables.p_hcd_electric_total_mw = 0.0e0

        # Ratio of fusion to input (injection+ohmic) power
        current_drive_variables.big_q_plasma = (
            physics_variables.p_fusion_total_mw
            / (
                current_drive_variables.p_hcd_injected_total_mw
                + current_drive_variables.p_beam_orbit_loss_mw
                + physics_variables.p_plasma_ohmic_mw
            )
        )

calculate_dimensionless_current_drive_efficiency(nd_plasma_electrons_vol_avg, rmajor, temp_plasma_electron_vol_avg_kev, c_hcd_driven, p_hcd_injected)

Calculate the dimensionless current drive efficiency, ζ.

This function computes the dimensionless current drive efficiency based on the average electron density, major radius, and electron temperature.

Parameters:

Name Type Description Default
nd_plasma_electrons_vol_avg float

Volume averaged electron density in m^-3.

required
rmajor float

Major radius of the plasma in meters.

required
temp_plasma_electron_vol_avg_kev float

Volume averaged electron temperature in keV.

required
c_hcd_driven float

Current driven by the heating and current drive system.

required
p_hcd_injected float

Power injected by the heating and current drive system.

required

Returns:

Type Description
float

The calculated dimensionless current drive efficiency.

References
Source code in process/models/physics/current_drive.py
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
def calculate_dimensionless_current_drive_efficiency(
    self,
    nd_plasma_electrons_vol_avg: float,
    rmajor: float,
    temp_plasma_electron_vol_avg_kev: float,
    c_hcd_driven: float,
    p_hcd_injected: float,
) -> float:
    """Calculate the dimensionless current drive efficiency, ζ.

    This function computes the dimensionless current drive efficiency
    based on the average electron density, major radius, and electron temperature.

    Parameters
    ----------
    nd_plasma_electrons_vol_avg:
        Volume averaged electron density in m^-3.
    rmajor:
        Major radius of the plasma in meters.
    temp_plasma_electron_vol_avg_kev:
        Volume averaged electron temperature in keV.
    c_hcd_driven:
        Current driven by the heating and current drive system.
    p_hcd_injected:
        Power injected by the heating and current drive system.

    Returns
    -------
    float
        The calculated dimensionless current drive efficiency.

    References
    ----------
    - E. Poli et al., “Electron-cyclotron-current-drive efficiency in DEMO plasmas,”
        Nuclear Fusion, vol. 53, no. 1, pp. 013011-013011, Dec. 2012,
        doi: https://doi.org/10.1088/0029-5515/53/1/013011.
    - T. C. Luce et al., “Generation of Localized Noninductive Current by Electron Cyclotron Waves on the DIII-D Tokamak,”
        Physical Review Letters, vol. 83, no. 22, pp. 4550-4553, Nov. 1999,
        doi: https://doi.org/10.1103/physrevlett.83.4550.
    """

    return (
        (constants.ELECTRON_CHARGE**3 / constants.EPSILON0**2)
        * (
            (nd_plasma_electrons_vol_avg * rmajor)
            / (temp_plasma_electron_vol_avg_kev * constants.KILOELECTRON_VOLT)
        )
        * (c_hcd_driven / p_hcd_injected)
    )

output_current_drive()

Output the current drive information to the output file. This method writes the current drive information to the output file.

Source code in process/models/physics/current_drive.py
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
def output_current_drive(self):
    """Output the current drive information to the output file.
    This method writes the current drive information to the output file.
    """

    po.oheadr(self.outfile, "Heating & Current Drive System")

    if physics_variables.i_plasma_ignited == 1:
        po.ocmmnt(
            self.outfile,
            "Ignited plasma; injected power only used for start-up phase",
        )

    if abs(physics_variables.f_c_plasma_inductive) > 1.0e-8:
        po.ocmmnt(
            self.outfile,
            "Current is driven by both inductive and non-inductive means.",
        )
        po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Fusion gain factor Q",
        "(big_q_plasma)",
        current_drive_variables.big_q_plasma,
        "OP ",
    )
    po.oblnkl(self.outfile)

    if current_drive_variables.i_hcd_calculations == 0:
        po.ocmmnt(self.outfile, "No current drive used")
        po.oblnkl(self.outfile)
        return

    po.ovarin(
        self.outfile,
        "Primary current drive efficiency model",
        "(i_hcd_primary)",
        current_drive_variables.i_hcd_primary,
    )

    if current_drive_variables.i_hcd_primary in [1, 4, 6]:
        po.ocmmnt(self.outfile, "Lower Hybrid Current Drive")
    elif current_drive_variables.i_hcd_primary == 2:
        po.ocmmnt(self.outfile, "Ion Cyclotron Current Drive")
    elif current_drive_variables.i_hcd_primary in [3, 7]:
        po.ocmmnt(self.outfile, "Electron Cyclotron Current Drive")
    elif current_drive_variables.i_hcd_primary in [5, 8]:
        po.ocmmnt(self.outfile, "Neutral Beam Current Drive")
    elif current_drive_variables.i_hcd_primary == 10:
        po.ocmmnt(
            self.outfile,
            "Electron Cyclotron Current Drive (input normalised efficiency)",
        )
    elif current_drive_variables.i_hcd_primary == 12:
        po.ocmmnt(self.outfile, "Electron Bernstein Wave Current Drive")
    elif current_drive_variables.i_hcd_primary == 13:
        po.ocmmnt(
            self.outfile,
            "Electron Cyclotron Current Drive (with Zeff & Te dependance)",
        )

    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Absolute current drive efficiency of primary system [A/W]",
        "(eta_cd_hcd_primary)",
        current_drive_variables.eta_cd_hcd_primary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Normalised current drive efficiency of primary system [10^20 A / Wm^2]",
        "(eta_cd_norm_hcd_primary)",
        current_drive_variables.eta_cd_norm_hcd_primary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Dimensionless current drive efficiency of primary system, ζ",
        "(eta_cd_dimensionless_hcd_primary)",
        current_drive_variables.eta_cd_dimensionless_hcd_primary,
        "OP ",
    )
    po.ovarre(
        self.mfile,
        "EBW coupling efficiency",
        "(xi_ebw)",
        current_drive_variables.xi_ebw,
    )
    if current_drive_variables.i_hcd_primary == 10:
        po.ovarre(
            self.outfile,
            "ECRH plasma heating efficiency",
            "(eta_cd_norm_ecrh)",
            current_drive_variables.eta_cd_norm_ecrh,
        )
    po.ovarre(
        self.outfile,
        "Power injected into plasma by primary system for current drive (MW)",
        "(p_hcd_primary_injected_mw)",
        current_drive_variables.p_hcd_primary_injected_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Extra power injected into plasma by primary system  (MW)",
        "(p_hcd_primary_extra_heat_mw)",
        current_drive_variables.p_hcd_primary_extra_heat_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Current driven in plasma by primary system (A)",
        "(c_hcd_primary_driven)",
        current_drive_variables.c_hcd_primary_driven,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Fraction of plasma current driven by primary system",
        "(f_c_plasma_hcd_primary)",
        current_drive_variables.f_c_plasma_hcd_primary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Wall plug to injector efficiency of primary system",
        "(eta_hcd_primary_injector_wall_plug)",
        current_drive_variables.eta_hcd_primary_injector_wall_plug,
        "IP ",
    )
    po.ovarre(
        self.outfile,
        "Wall plug electric power of primary system",
        "(p_hcd_primary_electric_mw)",
        heat_transport_variables.p_hcd_primary_electric_mw,
        "OP ",
    )

    if current_drive_variables.i_hcd_primary in [12, 13]:
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "ECRH / EBW harmonic number",
            "(n_ecrh_harmonic)",
            current_drive_variables.n_ecrh_harmonic,
        )
        po.ovarre(
            self.outfile,
            "EBW coupling efficiency",
            "(xi_ebw)",
            current_drive_variables.xi_ebw,
        )
    if current_drive_variables.i_hcd_primary == 13:
        po.ovarin(
            self.outfile,
            "Electron cyclotron cutoff wave mode switch",
            "(i_ecrh_wave_mode)",
            current_drive_variables.i_ecrh_wave_mode,
        )

    po.oblnkl(self.outfile)

    if current_drive_variables.i_hcd_primary in [5, 8]:
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Neutral beam power balance :")
        po.ocmmnt(self.outfile, "----------------------------")

        po.ovarre(
            self.outfile,
            "Neutral beam energy (keV)",
            "(e_beam_kev)",
            current_drive_variables.e_beam_kev,
        )
        if (current_drive_variables.i_hcd_primary == 5) or (
            current_drive_variables.i_hcd_primary == 8
        ):
            po.ovarre(
                self.outfile,
                "Neutral beam current (A)",
                "(c_beam_total)",
                current_drive_variables.c_beam_total,
                "OP ",
            )

        po.ovarre(
            self.outfile,
            "Neutral beam wall plug efficiency",
            "(eta_beam_injector_wall_plug)",
            current_drive_variables.eta_beam_injector_wall_plug,
        )
        po.ovarre(
            self.outfile,
            "Beam decay lengths to centre",
            "(n_beam_decay_lengths_core)",
            current_drive_variables.n_beam_decay_lengths_core,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Beam shine-through fraction",
            "(f_p_beam_shine_through)",
            current_drive_variables.f_p_beam_shine_through,
            "OP ",
        )

        if (current_drive_variables.i_hcd_primary == 5) or (
            current_drive_variables.i_hcd_primary == 8
        ):
            po.ovarrf(
                self.outfile,
                "Beam first orbit loss power (MW)",
                "(p_beam_orbit_loss_mw)",
                current_drive_variables.p_beam_orbit_loss_mw,
                "OP ",
            )
            po.ovarrf(
                self.outfile,
                "Beam shine-through power [MW]",
                "(p_beam_shine_through_mw)",
                current_drive_variables.p_beam_shine_through_mw,
                "OP ",
            )
            po.ovarrf(
                self.outfile,
                "Maximum allowable beam power (MW)",
                "(p_hcd_injected_max)",
                current_drive_variables.p_hcd_injected_max,
            )
            po.oblnkl(self.outfile)
            po.ovarrf(
                self.outfile,
                "Beam power entering vacuum vessel (MW)",
                "(p_beam_injected_mw)",
                current_drive_variables.p_beam_injected_mw,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Fraction of beam energy to ions",
                "(f_p_beam_injected_ions)",
                current_drive_variables.f_p_beam_injected_ions,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Beam duct shielding thickness (m)",
                "(dx_beam_shield)",
                current_drive_variables.dx_beam_shield,
            )
            po.ovarre(
                self.outfile,
                "Beam tangency radius / Plasma major radius",
                "(f_radius_beam_tangency_rmajor)",
                current_drive_variables.f_radius_beam_tangency_rmajor,
            )
            po.ovarre(
                self.outfile,
                "Beam centreline tangency radius (m)",
                "(radius_beam_tangency)",
                current_drive_variables.radius_beam_tangency,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Maximum possible tangency radius (m)",
                "(radius_beam_tangency_max)",
                current_drive_variables.radius_beam_tangency_max,
                "OP ",
            )

    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)
    po.ovarin(
        self.outfile,
        "Secondary current drive efficiency model",
        "(i_hcd_secondary)",
        current_drive_variables.i_hcd_secondary,
    )

    if current_drive_variables.i_hcd_secondary in [1, 4, 6]:
        po.ocmmnt(self.outfile, "Lower Hybrid Current Drive")
    elif current_drive_variables.i_hcd_secondary == 2:
        po.ocmmnt(self.outfile, "Ion Cyclotron Current Drive")
    elif current_drive_variables.i_hcd_secondary in [3, 7]:
        po.ocmmnt(self.outfile, "Electron Cyclotron Current Drive")
    elif current_drive_variables.i_hcd_secondary in [5, 8]:
        po.ocmmnt(self.outfile, "Neutral Beam Current Drive")
    elif current_drive_variables.i_hcd_secondary == 10:
        po.ocmmnt(
            self.outfile,
            "Electron Cyclotron Current Drive (input normalised efficiency)",
        )
    elif current_drive_variables.i_hcd_secondary == 12:
        po.ocmmnt(self.outfile, "Electron Bernstein Wave Current Drive")
    elif current_drive_variables.i_hcd_secondary == 13:
        po.ocmmnt(
            self.outfile,
            "Electron Cyclotron Current Drive (with Zeff & Te dependance)",
        )
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Absolute current drive efficiency of secondary system [A/W]",
        "(eta_cd_hcd_secondary)",
        current_drive_variables.eta_cd_hcd_secondary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Normalised current drive efficiency of secondary system [10^20 A / Wm^2]",
        "(eta_cd_norm_hcd_secondary)",
        current_drive_variables.eta_cd_norm_hcd_secondary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Dimensionless current drive efficiency of secondary system, ζ",
        "(eta_cd_dimensionless_hcd_secondary)",
        current_drive_variables.eta_cd_dimensionless_hcd_secondary,
        "OP ",
    )
    if current_drive_variables.i_hcd_secondary == 10:
        po.ovarre(
            self.outfile,
            "ECRH plasma heating efficiency",
            "(eta_cd_norm_ecrh)",
            current_drive_variables.eta_cd_norm_ecrh,
        )

    po.ovarre(
        self.outfile,
        "Power injected into plasma by secondary system (MW)",
        "(p_hcd_secondary_injected_mw)",
        current_drive_variables.p_hcd_secondary_injected_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Extra power injected into plasma by secondary system  (MW)",
        "(p_hcd_secondary_extra_heat_mw)",
        current_drive_variables.p_hcd_secondary_extra_heat_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Current driven in plasma by secondary system (A)",
        "(c_hcd_secondary_driven)",
        current_drive_variables.c_hcd_secondary_driven,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Fraction of plasma current driven by secondary system",
        "(f_c_plasma_hcd_secondary)",
        current_drive_variables.f_c_plasma_hcd_secondary,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Wall plug to injector efficiency of secondary system",
        "(eta_hcd_secondary_injector_wall_plug)",
        current_drive_variables.eta_hcd_secondary_injector_wall_plug,
        "IP ",
    )
    po.ovarre(
        self.outfile,
        "Wall plug electric power of secondary system",
        "(p_hcd_secondary_electric_mw)",
        heat_transport_variables.p_hcd_secondary_electric_mw,
        "OP ",
    )

    po.oblnkl(self.outfile)

    if current_drive_variables.i_hcd_secondary in [5, 8]:
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Neutral beam power balance :")
        po.ocmmnt(self.outfile, "----------------------------")

        po.ovarre(
            self.outfile,
            "Neutral beam energy (keV)",
            "(e_beam_kev)",
            current_drive_variables.e_beam_kev,
        )
        if (current_drive_variables.i_hcd_primary == 5) or (
            current_drive_variables.i_hcd_primary == 8
        ):
            po.ovarre(
                self.outfile,
                "Neutral beam current (A)",
                "(c_beam_total)",
                current_drive_variables.c_beam_total,
                "OP ",
            )

        po.ovarre(
            self.outfile,
            "Neutral beam wall plug efficiency",
            "(eta_beam_injector_wall_plug)",
            current_drive_variables.eta_beam_injector_wall_plug,
        )
        po.ovarre(
            self.outfile,
            "Beam decay lengths to centre",
            "(n_beam_decay_lengths_core)",
            current_drive_variables.n_beam_decay_lengths_core,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Beam shine-through fraction",
            "(f_p_beam_shine_through)",
            current_drive_variables.f_p_beam_shine_through,
            "OP ",
        )

        if (current_drive_variables.i_hcd_primary == 5) or (
            current_drive_variables.i_hcd_primary == 8
        ):
            po.ovarrf(
                self.outfile,
                "Beam first orbit loss power (MW)",
                "(p_beam_orbit_loss_mw)",
                current_drive_variables.p_beam_orbit_loss_mw,
                "OP ",
            )
            po.ovarrf(
                self.outfile,
                "Beam shine-through power [MW]",
                "(p_beam_shine_through_mw)",
                current_drive_variables.p_beam_shine_through_mw,
                "OP ",
            )
            po.ovarrf(
                self.outfile,
                "Maximum allowable beam power (MW)",
                "(p_hcd_injected_max)",
                current_drive_variables.p_hcd_injected_max,
            )
            po.oblnkl(self.outfile)
            po.ovarrf(
                self.outfile,
                "Beam power entering vacuum vessel (MW)",
                "(p_beam_injected_mw)",
                current_drive_variables.p_beam_injected_mw,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Fraction of beam energy to ions",
                "(f_p_beam_injected_ions)",
                current_drive_variables.f_p_beam_injected_ions,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Beam duct shielding thickness (m)",
                "(dx_beam_shield)",
                current_drive_variables.dx_beam_shield,
            )
            po.ovarre(
                self.outfile,
                "Beam tangency radius / Plasma major radius",
                "(f_radius_beam_tangency_rmajor)",
                current_drive_variables.f_radius_beam_tangency_rmajor,
            )
            po.ovarre(
                self.outfile,
                "Beam centreline tangency radius (m)",
                "(radius_beam_tangency)",
                current_drive_variables.radius_beam_tangency,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Maximum possible tangency radius (m)",
                "(radius_beam_tangency_max)",
                current_drive_variables.radius_beam_tangency_max,
                "OP ",
            )

    po.ocmmnt(self.outfile, "----------------------------")

    po.osubhd(self.outfile, "Totals :")

    po.ovarre(
        self.outfile,
        "Total injected heating power that drove plasma current (MW)",
        "(p_hcd_injected_current_total_mw)",
        current_drive_variables.p_hcd_injected_current_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Total injected heating power across all systems (MW)",
        "(p_hcd_injected_total_mw)",
        current_drive_variables.p_hcd_injected_total_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total injected heating power given to the electrons (MW)",
        "(p_hcd_injected_electrons_mw)",
        current_drive_variables.p_hcd_injected_electrons_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total injected heating power given to the ions (MW)",
        "(p_hcd_injected_ions_mw)",
        current_drive_variables.p_hcd_injected_ions_mw,
        "OP ",
    )

    po.ovarre(
        self.outfile,
        "Upper limit on total plasma injected power (MW)",
        "(p_hcd_injected_max)",
        current_drive_variables.p_hcd_injected_max,
        "OP ",
    )

    po.osubhd(self.outfile, "Contributions:")

    po.ovarre(
        self.outfile,
        "Injected power into plasma from lower hybrid systems (MW)",
        "(p_hcd_lowhyb_injected_total_mw)",
        current_drive_variables.p_hcd_lowhyb_injected_total_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Injected power into plasma from ion cyclotron systems (MW)",
        "(p_hcd_icrh_injected_total_mw)",
        current_drive_variables.p_hcd_icrh_injected_total_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Injected power into plasma from electron cyclotron systems (MW)",
        "(p_hcd_ecrh_injected_total_mw)",
        current_drive_variables.p_hcd_ecrh_injected_total_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Injected power into plasma from neutral beam systems (MW)",
        "(p_hcd_beam_injected_total_mw)",
        current_drive_variables.p_hcd_beam_injected_total_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Injected power into plasma from lower hybrid systems (MW)",
        "(p_hcd_ebw_injected_total_mw)",
        current_drive_variables.p_hcd_ebw_injected_total_mw,
        "OP ",
    )

    po.osubhd(self.outfile, "Fractions of current drive :")
    po.ovarrf(
        self.outfile,
        "Bootstrap fraction",
        "(f_c_plasma_bootstrap)",
        current_drive_variables.f_c_plasma_bootstrap,
        "OP ",
    )
    po.ovarrf(
        self.outfile,
        "Diamagnetic fraction",
        "(f_c_plasma_diamagnetic)",
        current_drive_variables.f_c_plasma_diamagnetic,
        "OP ",
    )
    po.ovarrf(
        self.outfile,
        "Pfirsch-Schlueter fraction",
        "(f_c_plasma_pfirsch_schluter)",
        current_drive_variables.f_c_plasma_pfirsch_schluter,
        "OP ",
    )
    po.ovarrf(
        self.outfile,
        "Auxiliary current drive fraction",
        "(f_c_plasma_auxiliary)",
        physics_variables.f_c_plasma_auxiliary,
        "OP ",
    )
    po.ovarrf(
        self.outfile,
        "Inductive fraction",
        "(f_c_plasma_inductive)",
        physics_variables.f_c_plasma_inductive,
        "OP ",
    )

    # MDK Add physics_variables.f_c_plasma_non_inductive as it can be an iteration variable
    po.ovarrf(
        self.outfile,
        "Fraction of the plasma current produced by non-inductive means",
        "(f_c_plasma_non_inductive)",
        physics_variables.f_c_plasma_non_inductive,
    )

    if (
        abs(
            current_drive_variables.f_c_plasma_bootstrap
            - current_drive_variables.f_c_plasma_bootstrap_max
        )
        < 1.0e-8
    ):
        po.ocmmnt(self.outfile, "Warning : bootstrap current fraction is at")
        po.ocmmnt(self.outfile, "          its prescribed maximum.")

    po.oblnkl(self.outfile)