Skip to content

poloidal

Geometry functions for PROCESS summary plots.

poloidal_cross_section(axis, mfile, scan, demo_ranges, radial_build, colour_scheme)

Function to plot poloidal cross-section

Parameters:

Name Type Description Default
axis Axes

axis object to add plot to

required
mfile MFile

MFILE data object

required
scan int

scan number to use

required
demo_ranges bool
required
colour_scheme Literal[1, 2]

colour scheme to use for plots

required
Source code in process/core/io/plot/summary/geometry/poloidal.py
 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
def poloidal_cross_section(
    axis: plt.Axes,
    mfile: MFile,
    scan: int,
    demo_ranges: bool,
    radial_build: RadialBuild,
    colour_scheme: Literal[1, 2],
):
    """Function to plot poloidal cross-section

    Parameters
    ----------
    axis :
        axis object to add plot to
    mfile :
        MFILE data object
    scan :
        scan number to use
    demo_ranges:

    colour_scheme :
        colour scheme to use for plots
    """
    axis.set_xlabel("R [m]")
    axis.set_ylabel("Z [m]")
    axis.set_title("Poloidal Cross-Section")
    axis.minorticks_on()
    axis.grid(which="both", linestyle="--", linewidth=0.5, alpha=0.2)

    plot_vacuum_vessel_and_divertor(axis, mfile, scan, radial_build, colour_scheme)
    plot_shield(axis, mfile, scan, radial_build, colour_scheme)
    plot_blanket(axis, mfile, scan, radial_build, colour_scheme)
    plot_firstwall(axis, mfile, scan, radial_build, colour_scheme)

    plot_plasma(axis, mfile, scan, colour_scheme)
    plot_centre_cross(axis, mfile, scan)
    plot_cryostat(axis, mfile, scan, colour_scheme)

    plot_tf_coils(axis, mfile, scan, colour_scheme)
    plot_pf_coils(axis, mfile, scan, colour_scheme)

    if demo_ranges:
        axis.set_ylim(-15, 15)
        axis.set_xlim(0, 20)

    else:
        axis.set_xlim(0, axis.get_xlim()[1])

plot_full_machine_poloidal_cross_section(axis, mfile, scan, radial_build, colour_scheme)

Function to plot full machine poloidal cross-section, including mirrored negative x-axis

Parameters:

Name Type Description Default
axis Axes

axis object to add plot to

required
mfile MFile

MFILE data object

required
scan int

scan number to use

required
radial_build RadialBuild

radial build data

required
colour_scheme Literal[1, 2]

colour scheme to use for plots

required
Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_full_machine_poloidal_cross_section(
    axis: plt.Axes,
    mfile: MFile,
    scan: int,
    radial_build: RadialBuild,
    colour_scheme: Literal[1, 2],
):
    """Function to plot full machine poloidal cross-section, including mirrored negative
    x-axis

    Parameters
    ----------
    axis :
        axis object to add plot to
    mfile :
        MFILE data object
    scan :
        scan number to use
    radial_build :
        radial build data
    colour_scheme :
        colour scheme to use for plots
    """
    plot_vacuum_vessel_and_divertor(axis, mfile, scan, radial_build, colour_scheme)
    plot_vacuum_vessel_and_divertor(
        axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=True
    )
    plot_shield(axis, mfile, scan, radial_build, colour_scheme)
    plot_shield(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=True)

    plot_blanket(axis, mfile, scan, radial_build, colour_scheme)
    plot_blanket(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=True)
    plot_firstwall(axis, mfile, scan, radial_build, colour_scheme)
    plot_firstwall(
        axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=True
    )
    plot_plasma(axis, mfile, scan, colour_scheme)
    plot_plasma(axis, mfile, scan, colour_scheme, mirror_negative_x=True)
    plot_centre_cross(axis, mfile, scan)
    plot_centre_cross(axis, mfile, scan, mirror_negative_x=True)
    plot_cryostat(axis, mfile, scan, colour_scheme)
    plot_cryostat(axis, mfile, scan, colour_scheme, mirror_negative_x=True)
    plot_tf_coils(axis, mfile, scan, colour_scheme)
    plot_tf_coils(axis, mfile, scan, colour_scheme, mirror_negative_x=True)
    plot_pf_coils(axis, mfile, scan, colour_scheme)
    plot_pf_coils(axis, mfile, scan, colour_scheme, mirror_negative_x=True)

    axis.set_xlabel("R [m]")
    axis.set_ylabel("Z [m]")
    axis.set_aspect("equal")
    axis.minorticks_on()
    axis.grid(which="minor", linestyle=":", linewidth=0.5, alpha=0.5)

plot_cryostat(axis, mfile, scan, colour_scheme, mirror_negative_x=False)

Function to plot cryostat in poloidal cross-section

Parameters:

Name Type Description Default
axis Axes

axis object to plot to

required
mfile MFile

MFILE data object

required
scan int

scan number to use

required
colour_scheme Literal[1, 2]

colour scheme to use for plots

required
mirror_negative_x bool

if True, mirror the plot to the negative x-axis (Default value = False)

False
Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_cryostat(
    axis: plt.Axes,
    mfile: MFile,
    scan: int,
    colour_scheme: Literal[1, 2],
    mirror_negative_x: bool = False,
):
    """Function to plot cryostat in poloidal cross-section

    Parameters
    ----------
    axis : plt.Axes
        axis object to plot to
    mfile : MFile
        MFILE data object
    scan : int
        scan number to use
    colour_scheme : Literal[1, 2]
        colour scheme to use for plots
    mirror_negative_x : bool
        if True, mirror the plot to the negative x-axis (Default value = False)
    """
    rects = cryostat_geometry(
        r_cryostat_inboard=mfile.get("r_cryostat_inboard", scan=scan),
        dr_cryostat=mfile.get("dr_cryostat", scan=scan),
        z_cryostat_half_inside=mfile.get("z_cryostat_half_inside", scan=scan),
    )

    # Apply mirror transformation if requested
    x_scale = -1 if mirror_negative_x else 1

    for rec in rects:
        axis.add_patch(
            patches.Rectangle(
                xy=(x_scale * rec.anchor_x, rec.anchor_z),
                width=x_scale * rec.width,
                height=rec.height,
                facecolor=CRYOSTAT_COLOUR[colour_scheme - 1],
            )
        )

plot_vacuum_vessel_and_divertor(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=False)

Function to plot vacuum vessel and divertor boxes

Parameters:

Name Type Description Default
axis

axis object to plot to

required
mfile MFile

MFILE data object

required
scan

scan number to use

required
radial_build
required
colour_scheme

colour scheme to use for plots

required
mirror_negative_x bool

if True, mirror the plot to the negative x-axis (Default value = False)

False
Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_vacuum_vessel_and_divertor(
    axis,
    mfile: MFile,
    scan,
    radial_build,
    colour_scheme,
    mirror_negative_x: bool = False,
):
    """Function to plot vacuum vessel and divertor boxes

    Parameters
    ----------
    axis :
        axis object to plot to
    mfile :
        MFILE data object
    scan :
        scan number to use
    radial_build :

    colour_scheme :
        colour scheme to use for plots
    mirror_negative_x :
        if True, mirror the plot to the negative x-axis (Default value = False)
    """
    cumulative_upper = radial_build.cumulative_upper
    cumulative_lower = radial_build.cumulative_lower
    upper = radial_build.upper
    lower = radial_build.lower

    i_single_null = int(mfile.get("i_single_null", scan=scan))
    triang_95 = mfile.get("triang95", scan=scan)
    dz_divertor = mfile.get("dz_divertor", scan=scan)
    dz_xpoint_divertor = mfile.get("dz_xpoint_divertor", scan=scan)
    kappa = mfile.get("kappa", scan=scan)
    rminor = mfile.get("rminor", scan=scan)
    dr_vv_inboard = mfile.get("dr_vv_inboard", scan=scan)
    dr_vv_outboard = mfile.get("dr_vv_outboard", scan=scan)
    dr_shld_inboard = mfile.get("dr_shld_inboard", scan=scan)
    dr_shld_outboard = mfile.get("dr_shld_outboard", scan=scan)
    dr_blkt_inboard = mfile.get("dr_blkt_inboard", scan=scan)
    dr_blkt_outboard = mfile.get("dr_blkt_outboard", scan=scan)

    # Outer side (furthest from plasma)
    radx_outer = (
        cumulative_radial_build("dr_vv_outboard", mfile, scan)
        + cumulative_radial_build("dr_shld_vv_gap_inboard", mfile, scan)
    ) / 2.0
    rminx_outer = (
        cumulative_radial_build("dr_vv_outboard", mfile, scan)
        - cumulative_radial_build("dr_shld_vv_gap_inboard", mfile, scan)
    ) / 2.0

    # Inner side (nearest to the plasma)
    radx_inner = (
        cumulative_radial_build("dr_shld_outboard", mfile, scan)
        + cumulative_radial_build("dr_vv_inboard", mfile, scan)
    ) / 2.0
    rminx_inner = (
        cumulative_radial_build("dr_shld_outboard", mfile, scan)
        - cumulative_radial_build("dr_vv_inboard", mfile, scan)
    ) / 2.0

    z_divertor_lower_top = (-kappa * rminor) - dz_xpoint_divertor
    z_divertor_lower_bottom = z_divertor_lower_top - dz_divertor

    # Apply mirror transformation if requested
    x_scale = -1 if mirror_negative_x else 1

    match DivertorNumberModels(i_single_null):
        case DivertorNumberModels.SINGLE_NULL:
            z_divertor_upper_bottom = None
            z_divertor_upper_top = None
            vvg_single_null = vacuum_vessel_geometry_single_null(
                cumulative_upper=cumulative_upper,
                upper=upper,
                triang=triang_95,
                radx_outer=radx_outer,
                rminx_outer=rminx_outer,
                radx_inner=radx_inner,
                rminx_inner=rminx_inner,
                cumulative_lower=cumulative_lower,
                lower=lower,
            )

            axis.plot(
                x_scale * np.array(vvg_single_null.rs),
                vvg_single_null.zs,
                color="black",
                lw=0,
                zorder=5,
            )

            axis.fill(
                x_scale * np.array(vvg_single_null.rs),
                vvg_single_null.zs,
                color=VESSEL_COLOUR[colour_scheme - 1],
                lw=0.01,
                zorder=5,
            )

            # Find indices where vessel boundary is between z_divertor_bottom and
            # z_divertor_top
            # Find the min and max R values of the vessel boundary between the divertor
            # lines
            mask = (vvg_single_null.zs >= z_divertor_lower_bottom) & (
                vvg_single_null.zs <= z_divertor_lower_top
            )
            # Get the min/max R for the region between the divertor lines
            r_min = (
                np.min(vvg_single_null.rs[mask])
                + dr_vv_inboard
                + dr_shld_inboard
                + (dr_blkt_inboard * 0.5)
            )
            r_max = (
                np.max(vvg_single_null.rs[mask])
                - dr_vv_outboard
                - dr_shld_outboard
                - (dr_blkt_outboard * 0.5)
            )
            # Draw a rectangle (box) between the two lines and inside the vessel
            axis.add_patch(
                patches.Rectangle(
                    (
                        x_scale * r_min,
                        z_divertor_lower_bottom,
                    ),
                    x_scale * (r_max - r_min),
                    z_divertor_lower_top - z_divertor_lower_bottom,
                    facecolor="black",
                    alpha=0.8,
                    zorder=1,
                )
            )

        case DivertorNumberModels.DOUBLE_NULL:
            z_divertor_upper_bottom = (kappa * rminor) + dz_xpoint_divertor
            z_divertor_upper_top = z_divertor_upper_bottom + dz_divertor
            vvg_double_null = vacuum_vessel_geometry_double_null(
                cumulative_lower=cumulative_lower,
                lower=lower,
                radx_inner=radx_inner,
                radx_outer=radx_outer,
                rminx_inner=rminx_inner,
                rminx_outer=rminx_outer,
                triang=triang_95,
            )
            axis.plot(
                x_scale * np.array(vvg_double_null.rs),
                vvg_double_null.zs,
                color="black",
                lw=0,
                zorder=5,
            )

            axis.fill(
                x_scale * np.array(vvg_double_null.rs),
                vvg_double_null.zs,
                color=VESSEL_COLOUR[colour_scheme - 1],
                lw=0.01,
                zorder=5,
            )

            # Plot lower divertor
            # Find indices where vessel boundary is between z_divertor_bottom and
            # z_divertor_top
            # Find the min and max R values of the vessel boundary between the divertor
            # lines
            mask = (vvg_double_null.zs >= z_divertor_lower_bottom) & (
                vvg_double_null.zs <= z_divertor_lower_top
            )
            # Get the min/max R for the region between the divertor lines
            r_min = (
                np.min(vvg_double_null.rs[mask])
                + dr_vv_inboard
                + dr_shld_inboard
                + (dr_blkt_inboard * 0.5)
            )
            r_max = (
                np.max(vvg_double_null.rs[mask])
                - dr_vv_outboard
                - dr_shld_outboard
                - (dr_blkt_outboard * 0.5)
            )
            # Draw a rectangle (box) between the two lines and inside the vessel
            axis.add_patch(
                patches.Rectangle(
                    (
                        x_scale * r_min,
                        z_divertor_lower_bottom,
                    ),
                    x_scale * (r_max - r_min),
                    z_divertor_lower_top - z_divertor_lower_bottom,
                    facecolor="black",
                    alpha=0.8,
                    zorder=1,
                )
            )
            # Plot upper divertor
            # Find indices where vessel boundary is between z_divertor_bottom and
            # z_divertor_top
            # Find the min and max R values of the vessel boundary between the divertor
            # lines
            mask = (vvg_double_null.zs >= z_divertor_upper_bottom) & (
                vvg_double_null.zs <= z_divertor_upper_top
            )
            # Get the min/max R for the region between the divertor lines
            r_min = (
                np.min(vvg_double_null.rs[mask])
                + dr_vv_inboard
                + dr_shld_inboard
                + (dr_blkt_inboard * 0.5)
            )
            r_max = (
                np.max(vvg_double_null.rs[mask])
                - dr_vv_outboard
                - dr_shld_outboard
                - (dr_blkt_outboard * 0.5)
            )
            # Draw a rectangle (box) between the two lines and inside the vessel
            axis.add_patch(
                patches.Rectangle(
                    (
                        x_scale * r_min,
                        z_divertor_upper_bottom,
                    ),
                    x_scale * (r_max - r_min),
                    z_divertor_upper_top - z_divertor_upper_bottom,
                    facecolor="black",
                    alpha=0.8,
                    zorder=1,
                )
            )

plot_shield(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=False)

Function to plot shield

Parameters:

Name Type Description Default
axis Axes

axis object to plot to

required
mfile MFile

MFILE data object

required
scan int

scan number to use

required
radial_build
required
colour_scheme

colour scheme to use for plots

required
mirror_negative_x bool

if True, mirror the plot to the negative x-axis (Default value = False)

False
Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_shield(
    axis: plt.Axes,
    mfile: MFile,
    scan: int,
    radial_build,
    colour_scheme,
    mirror_negative_x: bool = False,
):
    """Function to plot shield

    Parameters
    ----------
    axis :
        axis object to plot to
    mfile :
        MFILE data object
    scan :
        scan number to use
    radial_build :

    colour_scheme :
        colour scheme to use for plots
    mirror_negative_x :
        if True, mirror the plot to the negative x-axis (Default value = False)

    """
    cumulative_upper = radial_build.cumulative_upper
    cumulative_lower = radial_build.cumulative_lower

    i_single_null = mfile.get("i_single_null", scan=scan)
    triang_95 = mfile.get("triang95", scan=scan)

    # Side furthest from plasma
    radx_far = (
        cumulative_radial_build("dr_shld_outboard", mfile, scan)
        + cumulative_radial_build("dr_vv_inboard", mfile, scan)
    ) / 2.0
    rminx_far = (
        cumulative_radial_build("dr_shld_outboard", mfile, scan)
        - cumulative_radial_build("dr_vv_inboard", mfile, scan)
    ) / 2.0

    # Side nearest to the plasma
    radx_near = (
        cumulative_radial_build("vvblgapo", mfile, scan)
        + cumulative_radial_build("dr_shld_inboard", mfile, scan)
    ) / 2.0
    rminx_near = (
        cumulative_radial_build("vvblgapo", mfile, scan)
        - cumulative_radial_build("dr_shld_inboard", mfile, scan)
    ) / 2.0

    # Apply mirror transformation if requested
    x_scale = -1 if mirror_negative_x else 1

    match DivertorNumberModels(i_single_null):
        case DivertorNumberModels.SINGLE_NULL:
            shield_geometry = shield_geometry_single_null(
                cumulative_upper=cumulative_upper,
                radx_far=radx_far,
                rminx_far=rminx_far,
                radx_near=radx_near,
                rminx_near=rminx_near,
                triang=triang_95,
                cumulative_lower=cumulative_lower,
            )
        case DivertorNumberModels.DOUBLE_NULL:
            shield_geometry = shield_geometry_double_null(
                cumulative_lower=cumulative_lower,
                radx_far=radx_far,
                radx_near=radx_near,
                rminx_far=rminx_far,
                rminx_near=rminx_near,
                triang=triang_95,
            )

    axis.plot(
        x_scale * np.array(shield_geometry.rs),
        shield_geometry.zs,
        color="black",
        lw=0,
    )
    axis.fill(
        x_scale * np.array(shield_geometry.rs),
        shield_geometry.zs,
        color=SHIELD_COLOUR[colour_scheme - 1],
        lw=0.01,
    )

plot_blanket(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=False)

Function to plot blanket

Parameters:

Name Type Description Default
axis Axes

axis object to plot to

required
mfile MFile

MFILE

required
scan

scan number to use

required
radial_build
required
colour_scheme

colour scheme to use for plots

required
mirror_negative_x bool

if True, mirror the plot to the negative x-axis (Default value = False)

False
Source code in process/core/io/plot/summary/geometry/poloidal.py
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
def plot_blanket(
    axis: plt.Axes,
    mfile: MFile,
    scan,
    radial_build,
    colour_scheme,
    mirror_negative_x: bool = False,
):
    """Function to plot blanket

    Parameters
    ----------
    axis :
        axis object to plot to
    mfile :
        MFILE
    scan :
        scan number to use
    radial_build :

    colour_scheme :
        colour scheme to use for plots
    mirror_negative_x :
        if True, mirror the plot to the negative x-axis (Default value = False)
    """
    cumulative_upper = radial_build.cumulative_upper
    cumulative_lower = radial_build.cumulative_lower

    dr_blkt_inboard = mfile.get("dr_blkt_inboard", scan=scan)
    dr_blkt_outboard = mfile.get("dr_blkt_outboard", scan=scan)
    # Single null: Draw top half from output
    # Double null: Reflect bottom half to top
    i_single_null = mfile.get("i_single_null", scan=scan)
    triang_95 = mfile.get("triang95", scan=scan)
    if int(i_single_null) == 1:
        dz_blkt_upper = mfile.get("dz_blkt_upper", scan=scan)
    else:
        dz_blkt_upper = 0.0

    c_shldith = cumulative_radial_build("dr_shld_inboard", mfile, scan)
    c_blnkoth = cumulative_radial_build("dr_blkt_outboard", mfile, scan)

    # Apply mirror transformation if requested
    x_scale = -1 if mirror_negative_x else 1

    match DivertorNumberModels(i_single_null):
        case DivertorNumberModels.SINGLE_NULL:
            # Upper blanket: outer surface
            radx_outer = (
                cumulative_radial_build("dr_blkt_outboard", mfile, scan)
                + cumulative_radial_build("vvblgapi", mfile, scan)
            ) / 2.0
            rminx_outer = (
                cumulative_radial_build("dr_blkt_outboard", mfile, scan)
                - cumulative_radial_build("vvblgapi", mfile, scan)
            ) / 2.0

            # Upper blanket: inner surface
            radx_inner = (
                cumulative_radial_build("dr_fw_outboard", mfile, scan)
                + cumulative_radial_build("dr_blkt_inboard", mfile, scan)
            ) / 2.0
            rminx_inner = (
                cumulative_radial_build("dr_fw_outboard", mfile, scan)
                - cumulative_radial_build("dr_blkt_inboard", mfile, scan)
            ) / 2.0
            bg_single_null = blanket_geometry_single_null(
                radx_outer=radx_outer,
                rminx_outer=rminx_outer,
                radx_inner=radx_inner,
                rminx_inner=rminx_inner,
                cumulative_upper=cumulative_upper,
                triang=triang_95,
                cumulative_lower=cumulative_lower,
                dz_blkt_upper=dz_blkt_upper,
                c_shldith=c_shldith,
                c_blnkoth=c_blnkoth,
                dr_blkt_inboard=dr_blkt_inboard,
                dr_blkt_outboard=dr_blkt_outboard,
            )

            # Plot blanket
            axis.plot(
                x_scale * np.array(bg_single_null.rs),
                bg_single_null.zs,
                color="black",
                lw=0,
                zorder=5,
            )

            axis.fill(
                x_scale * np.array(bg_single_null.rs),
                bg_single_null.zs,
                color=BLANKET_COLOUR[colour_scheme - 1],
                lw=0.01,
                zorder=5,
            )

        case DivertorNumberModels.DOUBLE_NULL:
            bg_double_null = blanket_geometry_double_null(
                cumulative_lower=cumulative_lower,
                triang=triang_95,
                dz_blkt_upper=dz_blkt_upper,
                c_shldith=c_shldith,
                c_blnkoth=c_blnkoth,
                dr_blkt_inboard=dr_blkt_inboard,
                dr_blkt_outboard=dr_blkt_outboard,
            )
            # Plot blanket
            axis.plot(
                x_scale * np.array(bg_double_null.rs[0]),
                bg_double_null.zs[0],
                color="black",
                lw=0,
            )
            axis.fill(
                x_scale * np.array(bg_double_null.rs[0]),
                bg_double_null.zs[0],
                color=BLANKET_COLOUR[colour_scheme - 1],
                lw=0.01,
                zorder=5,
            )
            if dr_blkt_inboard > 0.0:
                # only plot inboard blanket if inboard blanket thickness > 0
                axis.plot(
                    x_scale * np.array(bg_double_null.rs[1]),
                    bg_double_null.zs[1],
                    color="black",
                    lw=0,
                    zorder=5,
                )
                axis.fill(
                    x_scale * np.array(bg_double_null.rs[1]),
                    bg_double_null.zs[1],
                    color=BLANKET_COLOUR[colour_scheme - 1],
                    lw=0.01,
                    zorder=5,
                )

plot_first_wall_top_down_cross_section(axis, mfile, scan)

Plot first wall top down cross-section

Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_first_wall_top_down_cross_section(axis: plt.Axes, mfile: MFile, scan: int):
    """Plot first wall top down cross-section"""
    # Import required variables
    radius_fw_channel = mfile.get("radius_fw_channel", scan=scan) * 100
    dr_fw_wall = mfile.get("dr_fw_wall", scan=scan) * 100
    dx_fw_module = mfile.get("dx_fw_module", scan=scan) * 100

    # Flot first module
    axis.add_patch(
        patches.Rectangle(
            xy=(0, 0),
            width=dx_fw_module,
            height=2 * (dr_fw_wall + radius_fw_channel),
            edgecolor="black",
            facecolor="gray",
        )
    )

    # Plot cooling channel in first module
    axis.add_patch(
        patches.Circle(
            xy=(dx_fw_module / 2, dr_fw_wall + radius_fw_channel),
            radius=radius_fw_channel,
            edgecolor="black",
            facecolor="#b87333",
        )
    )

    # Plot second module
    axis.add_patch(
        patches.Rectangle(
            xy=(dx_fw_module, 0),
            width=dx_fw_module,
            height=2 * (dr_fw_wall + radius_fw_channel),
            edgecolor="black",
            facecolor="gray",
        )
    )

    # Plot cooling channel in second module
    axis.add_patch(
        patches.Circle(
            xy=(
                dx_fw_module + dx_fw_module / 2,
                dr_fw_wall + radius_fw_channel,
            ),
            radius=radius_fw_channel,
            edgecolor="black",
            facecolor="#b87333",
        )
    )

    # Draw radius line in the second circle
    axis.plot(
        [
            dx_fw_module + dx_fw_module / 2,
            dx_fw_module + dx_fw_module / 2 + radius_fw_channel * np.cos(np.pi / 4),
        ],
        [
            dr_fw_wall + radius_fw_channel,
            dr_fw_wall + radius_fw_channel + radius_fw_channel * np.sin(np.pi / 4),
        ],
        color="black",
        linestyle="--",
        label=f"$r_{{channel}}$ = {radius_fw_channel:.3f} cm",
    )

    # Draw width line below the second module
    axis.plot(
        [0, 0],
        [0, 0],
        color="black",
        label=f"$w_{{module}}$ = {dx_fw_module:.3f} cm",
    )
    axis.annotate(
        "",
        xy=(dx_fw_module, -0.2),
        xytext=(2 * dx_fw_module, -0.2),
        arrowprops={"arrowstyle": "<->", "color": "black"},
    )

    # Draw dotted line above the channel
    axis.plot(
        [dx_fw_module * 1.5, dx_fw_module * 1.5],
        [
            2 * radius_fw_channel + dr_fw_wall,
            2 * (radius_fw_channel + dr_fw_wall),
        ],
        color="black",
        linestyle="dotted",
        label=rf"$\Delta r_{{wall}}$ = {dr_fw_wall:.3f} cm",
    )

    # Draw dotted line below the channel
    axis.plot(
        [dx_fw_module * 1.5, dx_fw_module * 1.5],
        [0, dr_fw_wall],
        color="black",
        linestyle="dotted",
    )
    # Plot a dot in the center of the second channel
    axis.plot(
        dx_fw_module + dx_fw_module / 2,
        dr_fw_wall + radius_fw_channel,
        marker="o",
        color="black",
    )

    # Add the legend to the plot
    axis.legend()
    axis.grid(True, which="both", linestyle="--", linewidth=0.5, alpha=0.2)
    axis.set_xlabel("X [cm]")
    axis.set_ylabel("R [cm]")
    axis.set_title("First Wall Top-Down Cross Section")
    axis.set_xlim(-1, 2 * dx_fw_module + 1)
    axis.set_ylim(-1, 2 * (dr_fw_wall + radius_fw_channel) + 1)

plot_first_wall_poloidal_cross_section(axis, mfile, scan)

Plot first wall poloidal cross-section

Source code in process/core/io/plot/summary/geometry/poloidal.py
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
def plot_first_wall_poloidal_cross_section(axis: plt.Axes, mfile: MFile, scan: int):
    """Plot first wall poloidal cross-section"""
    # Import required variables
    radius_fw_channel = mfile.get("radius_fw_channel", scan=scan)
    dr_fw_wall = mfile.get("dr_fw_wall", scan=scan)
    dx_fw_module = mfile.get("dx_fw_module", scan=scan)
    len_fw_channel = mfile.get("len_fw_channel", scan=scan)
    temp_fw_coolant_in = mfile.get("temp_fw_coolant_in", scan=scan)
    temp_fw_coolant_out = mfile.get("temp_fw_coolant_out", scan=scan)
    i_fw_coolant_type = mfile.get("i_fw_coolant_type", scan=scan).strip("'\"")
    temp_fw_peak = mfile.get("temp_fw_peak", scan=scan)
    pres_fw_coolant = mfile.get("pres_fw_coolant", scan=scan)
    n_fw_outboard_channels = mfile.get("n_fw_outboard_channels", scan=scan)
    n_fw_inboard_channels = mfile.get("n_fw_inboard_channels", scan=scan)

    # Plot first wall structure facing plasma
    axis.add_patch(
        patches.Rectangle(
            xy=(0, 0),
            width=dr_fw_wall,
            height=len_fw_channel,
            edgecolor="black",
            facecolor="gray",
        )
    )

    # Plot the cooling channel
    axis.add_patch(
        patches.Rectangle(
            xy=(dr_fw_wall, 0),
            width=2 * radius_fw_channel,
            height=len_fw_channel,
            edgecolor="black",
            facecolor="#b87333",  # Copper color
        )
    )

    # Plot the back wall of the first wall
    axis.add_patch(
        patches.Rectangle(
            xy=(dr_fw_wall + 2 * radius_fw_channel, 0),
            width=dr_fw_wall,
            height=len_fw_channel,
            edgecolor="black",
            facecolor="grey",
        )
    )

    # Draw an upward pointing arrow
    axis.arrow(
        dx_fw_module + 0.5 * dr_fw_wall,
        dr_fw_wall + radius_fw_channel,
        0,
        len_fw_channel / 6,
        head_width=dr_fw_wall,
        head_length=len_fw_channel / 20,
        fc="black",
        ec="black",
    )

    # Add the inlet temperature beside the arrow
    axis.text(
        dx_fw_module + 2 * dr_fw_wall,
        dr_fw_wall + radius_fw_channel + len_fw_channel / 6,
        f"$T_{{inlet}} = ${temp_fw_coolant_in:.2f} K",
        ha="left",
        va="bottom",
        fontsize=10,
        color="black",
    )

    # Draw a right pointing arrow
    axis.arrow(
        dx_fw_module + 0.5 * dr_fw_wall,
        len_fw_channel,
        2 * dr_fw_wall,
        0,
        head_width=len_fw_channel / 30,
        head_length=dr_fw_wall,
        fc="black",
        ec="black",
        linewidth=5,  # Thicker stem
    )

    # Add the outlet temperature beside the arrow
    axis.text(
        dx_fw_module + 0.5 * dr_fw_wall,
        len_fw_channel * 0.9,
        f"$T_{{outlet}} = ${temp_fw_coolant_out:.2f} K",
        ha="left",
        va="bottom",
        fontsize=10,
        color="black",
    )

    textstr_fw = "\n".join((
        rf"Coolant type: {i_fw_coolant_type}",
        rf"$T_{{FW,peak}}$: {temp_fw_peak:,.3f} K",
        rf"$P_{{FW}}$: {pres_fw_coolant / 1e3:,.3f} kPa",
        rf"$P_{{FW}}$: {pres_fw_coolant / 1e5:,.3f} bar",
        rf"$N_{{outboard}}$: {n_fw_outboard_channels}",
        rf"$N_{{inboard}}$: {n_fw_inboard_channels}",
    ))

    props_fw = {"boxstyle": "round", "facecolor": "wheat", "alpha": 0.5}
    axis.text(
        -0.5,
        0.05,
        textstr_fw,
        transform=axis.transAxes,
        fontsize=11,
        verticalalignment="bottom",
        bbox=props_fw,
    )

    axis.set_xlabel("R [m]")
    axis.set_ylabel("Z [m]")
    axis.set_title("First Wall Poloidal Cross Section")
    axis.set_xlim(-0.01, (dx_fw_module + radius_fw_channel * 2) + 0.01)
    axis.set_ylim(-0.2, len_fw_channel + 0.2)

plot_firstwall(axis, mfile, scan, radial_build, colour_scheme, mirror_negative_x=False)

Function to plot first wall

Parameters:

Name Type Description Default
axis Axes

axis object to plot to

required
mfile MFile

MFILE

required
scan int

scan number to use

required
radial_build
required
colour_scheme

colour scheme to use for plots

required
mirror_negative_x bool

if True, mirror the plot to the negative x-axis (Default value = False)

False
Source code in process/core/io/plot/summary/geometry/poloidal.py
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
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
def plot_firstwall(
    axis: plt.Axes,
    mfile: MFile,
    scan: int,
    radial_build,
    colour_scheme,
    mirror_negative_x: bool = False,
):
    """Function to plot first wall

    Parameters
    ----------
    axis :
        axis object to plot to
    mfile :
        MFILE
    scan :
        scan number to use
    radial_build :

    colour_scheme :
        colour scheme to use for plots
    mirror_negative_x :
        if True, mirror the plot to the negative x-axis (Default value = False)
    """
    cumulative_upper = radial_build.cumulative_upper
    cumulative_lower = radial_build.cumulative_lower

    i_single_null = mfile.get("i_single_null", scan=scan)
    triang_95 = mfile.get("triang95", scan=scan)
    if int(i_single_null) == 1:
        dz_blkt_upper = mfile.get("dz_blkt_upper", scan=scan)
        tfwvt = mfile.get("dz_fw_upper", scan=scan)
    else:
        dz_blkt_upper = tfwvt = 0.0

    c_blnkith = cumulative_radial_build("dr_blkt_inboard", mfile, scan)
    c_fwoth = cumulative_radial_build("dr_fw_outboard", mfile, scan)

    dr_fw_inboard = mfile.get("dr_fw_inboard", scan=scan)
    dr_fw_outboard = mfile.get("dr_fw_outboard", scan=scan)

    # Apply mirror transformation if requested
    x_scale = -1 if mirror_negative_x else 1

    match DivertorNumberModels(i_single_null):
        case DivertorNumberModels.SINGLE_NULL:
            # Upper first wall: outer surface
            radx_outer = (
                cumulative_radial_build("dr_fw_outboard", mfile, scan)
                + cumulative_radial_build("dr_blkt_inboard", mfile, scan)
            ) / 2.0
            rminx_outer = (
                cumulative_radial_build("dr_fw_outboard", mfile, scan)
                - cumulative_radial_build("dr_blkt_inboard", mfile, scan)
            ) / 2.0

            # Upper first wall: inner surface
            radx_inner = (
                cumulative_radial_build("dr_fw_plasma_gap_outboard", mfile, scan)
                + cumulative_radial_build("dr_fw_inboard", mfile, scan)
            ) / 2.0
            rminx_inner = (
                cumulative_radial_build("dr_fw_plasma_gap_outboard", mfile, scan)
                - cumulative_radial_build("dr_fw_inboard", mfile, scan)
            ) / 2.0

            fwg_single_null = first_wall_geometry_single_null(
                radx_outer=radx_outer,
                rminx_outer=rminx_outer,
                radx_inner=radx_inner,
                rminx_inner=rminx_inner,
                cumulative_upper=cumulative_upper,
                triang=triang_95,
                cumulative_lower=cumulative_lower,
                dz_blkt_upper=dz_blkt_upper,
                c_blnkith=c_blnkith,
                c_fwoth=c_fwoth,
                dr_fw_inboard=dr_fw_inboard,
                dr_fw_outboard=dr_fw_outboard,
                tfwvt=tfwvt,
            )

            # Plot first wall
            axis.plot(
                x_scale * np.array(fwg_single_null.rs),
                fwg_single_null.zs,
                color="black",
                lw=0,
            )
            axis.fill(
                x_scale * np.array(fwg_single_null.rs),
                fwg_single_null.zs,
                color=FIRSTWALL_COLOUR[colour_scheme - 1],
                lw=0.01,
            )

        case DivertorNumberModels.DOUBLE_NULL:
            fwg_double_null = first_wall_geometry_double_null(
                cumulative_lower=cumulative_lower,
                triang=triang_95,
                dz_blkt_upper=dz_blkt_upper,
                c_blnkith=c_blnkith,
                c_fwoth=c_fwoth,
                dr_fw_inboard=dr_fw_inboard,
                dr_fw_outboard=dr_fw_outboard,
                tfwvt=tfwvt,
            )
            # Plot first wall
            axis.plot(
                x_scale * np.array(fwg_double_null.rs[0]),
                fwg_double_null.zs[0],
                color="black",
                lw=0,
            )
            axis.plot(
                x_scale * np.array(fwg_double_null.rs[1]),
                fwg_double_null.zs[1],
                color="black",
                lw=0,
            )
            axis.fill(
                x_scale * np.array(fwg_double_null.rs[0]),
                fwg_double_null.zs[0],
                color=FIRSTWALL_COLOUR[colour_scheme - 1],
                lw=0.01,
            )
            axis.fill(
                x_scale * np.array(fwg_double_null.rs[1]),
                fwg_double_null.zs[1],
                color=FIRSTWALL_COLOUR[colour_scheme - 1],
                lw=0.01,
            )