-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathplot_proc.py
More file actions
13346 lines (12034 loc) · 438 KB
/
plot_proc.py
File metadata and controls
13346 lines (12034 loc) · 438 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
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
"""
PROCESS plot_proc using process_io_lib functions and MFILE.DAT
James Morris
13/04/2014
CCFE
Revised by Michael Kovari, 7/1/2016
24/11/2021: Global dictionary variables moved within the functions
to avoid cyclic dependencies. This is because the dicts
generation script imports, and inspects, process.
"""
import argparse
import json
import os
import textwrap
from argparse import RawTextHelpFormatter
from importlib import resources
import matplotlib as mpl
import matplotlib.backends.backend_pdf as bpdf
import matplotlib.image as mpimg
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle, Rectangle
from matplotlib.path import Path
from scipy.interpolate import interp1d
import process.confinement_time as confine
import process.constants as constants
import process.data_structure.pfcoil_variables as pfcoil_variables
import process.io.mfile as mf
import process.superconducting_tf_coil as sctf
from process.build import Build
from process.data_structure import impurity_radiation_module, physics_variables
from process.geometry.blanket_geometry import (
blanket_geometry_double_null,
blanket_geometry_single_null,
)
from process.geometry.cryostat_geometry import cryostat_geometry
from process.geometry.firstwall_geometry import (
first_wall_geometry_double_null,
first_wall_geometry_single_null,
)
from process.geometry.pfcoil_geometry import pfcoil_geometry
from process.geometry.plasma_geometry import plasma_geometry
from process.geometry.shield_geometry import (
shield_geometry_double_null,
shield_geometry_single_null,
)
from process.geometry.tfcoil_geometry import (
tfcoil_geometry_d_shape,
tfcoil_geometry_rectangular_shape,
)
from process.geometry.vacuum_vessel_geometry import (
vacuum_vessel_geometry_double_null,
vacuum_vessel_geometry_single_null,
)
from process.impurity_radiation import read_impurity_file
from process.io.mfile import MFileErrorClass
from process.objectives import OBJECTIVE_NAMES
from process.superconducting_tf_coil import SUPERCONDUCTING_TF_TYPES
if os.name == "posix" and "DISPLAY" not in os.environ:
mpl.use("Agg")
mpl.rcParams["figure.max_open_warning"] = 40
def parse_args(args):
"""Parse supplied arguments.
:param args: arguments to parse
:type args: list, None
:return: parsed arguments
:rtype: Namespace
"""
# Setup command line arguments
parser = argparse.ArgumentParser(
description="Produces a three page summary of the PROCESS MFILE output, using the MFILE. "
"For info please see https://github.com/ukaea/PROCESS?tab=readme-ov-file#contacts ",
formatter_class=RawTextHelpFormatter,
)
parser.add_argument(
"-f",
metavar="FILENAME",
type=str,
default="",
help="specify input/output file path",
)
parser.add_argument("-s", "--show", help="show plot", action="store_true")
parser.add_argument("-n", type=int, help="Which scan to plot?")
parser.add_argument(
"-d",
"--DEMO_ranges",
help="Uses the DEMO dimensions as ranges for all graphics",
action="store_true",
)
parser.add_argument(
"-c",
"--colour",
type=int,
help=(
"Which colour scheme to use for cross-section plots\n"
"1: Original PROCESS (default)\n"
"2: BLUEMIRA"
),
default=1,
)
return parser.parse_args(args)
# Colours are PROCESS defualt, BLUEMIRA
SOLENOID_COLOUR = ["pink", "#1764ab"]
CSCOMPRESSION_COLOUR = ["maroon", "#33CCCC"]
TFC_COLOUR = ["cyan", "#084a91"]
THERMAL_SHIELD_COLOUR = ["gray", "#e3eef9"]
VESSEL_COLOUR = ["green", "#b7d4ea"]
SHIELD_COLOUR = ["green", "#94c4df"]
BLANKET_COLOUR = ["magenta", "#4a98c9"]
PLASMA_COLOUR = ["khaki", "#cc8acc"]
CRYOSTAT_COLOUR = ["red", "#2e7ebc"]
FIRSTWALL_COLOUR = ["darkblue", "darkblue"]
NBSHIELD_COLOUR = ["black", "black"]
thin = 0.0
RADIAL_BUILD = [
"dr_bore",
"dr_cs",
"dr_cs_precomp",
"dr_cs_tf_gap",
"dr_tf_inboard",
"dr_tf_shld_gap",
"dr_shld_thermal_inboard",
"dr_shld_vv_gap_inboard",
"dr_vv_inboard",
"dr_shld_inboard",
"vvblgapi",
"dr_blkt_inboard",
"dr_fw_inboard",
"dr_fw_plasma_gap_inboard",
"rminori",
"rminoro",
"dr_fw_plasma_gap_outboard",
"dr_fw_outboard",
"dr_blkt_outboard",
"vvblgapo",
"dr_shld_outboard",
"dr_vv_outboard",
"dr_shld_vv_gap_outboard",
"dr_shld_thermal_outboard",
"dr_tf_shld_gap",
"dr_tf_outboard",
]
vertical_lower = [
"z_plasma_xpoint_lower",
"dz_xpoint_divertor",
"dz_divertor",
"dz_shld_lower",
"dz_vv_lower",
"dz_shld_vv_gap",
"dz_shld_thermal",
"dr_tf_shld_gap",
"dr_tf_inboard",
]
ANIMATION_INFO = [
("rmajor", "Major radius", "m"),
("rminor", "Minor radius", "m"),
("aspect", "Aspect ratio", ""),
]
rtangle = np.pi / 2
rtangle2 = 2 * rtangle
def plot_plasma(axis, mfile_data, scan, colour_scheme):
"""Plots the plasma boundary arcs.
Arguments:
axis --> axis object to plot to
mfile_data --> MFILE data object
scan --> scan number to use
colour_scheme --> colour scheme to use for plots
"""
r_0 = mfile_data.data["rmajor"].get_scan(scan)
a = mfile_data.data["rminor"].get_scan(scan)
triang = mfile_data.data["triang"].get_scan(scan)
kappa = mfile_data.data["kappa"].get_scan(scan)
i_single_null = mfile_data.data["i_single_null"].get_scan(scan)
i_plasma_shape = mfile_data.data["i_plasma_shape"].get_scan(scan)
plasma_square = mfile_data.data["plasma_square"].get_scan(scan)
pg = plasma_geometry(
rmajor=r_0,
rminor=a,
triang=triang,
kappa=kappa,
i_single_null=i_single_null,
i_plasma_shape=i_plasma_shape,
square=plasma_square,
)
if i_plasma_shape == 0:
# Plot the 2 plasma outline arcs.
axis.plot(pg.rs[0], pg.zs[0], color="black")
axis.plot(pg.rs[1], pg.zs[1], color="black")
# Set triang_95 to stop plotting plasma past boundary
# Assume IPDG scaling
triang_95 = triang / 1.5
# Colour in right side of plasma
axis.fill_between(
x=pg.rs[0],
y1=pg.zs[0],
where=(pg.rs[0] > r_0 - (triang_95 * a * 1.5)),
color=PLASMA_COLOUR[colour_scheme - 1],
)
# Colour in left side of plasma
axis.fill_between(
x=pg.rs[1],
y1=pg.zs[1],
where=(pg.rs[1] < r_0 - (triang_95 * a * 1.5)),
color=PLASMA_COLOUR[colour_scheme - 1],
)
elif i_plasma_shape == 1:
axis.plot(pg.rs, pg.zs, color="black")
axis.fill(pg.rs, pg.zs, color=PLASMA_COLOUR[colour_scheme - 1])
def plot_centre_cross(axis, mfile_data, scan):
"""Function to plot centre cross on plot
Arguments:
axis --> axis object to plot to
mfile_data --> MFILE data object
scan --> scan number to use
"""
rmajor = mfile_data.data["rmajor"].get_scan(scan)
axis.plot(
[rmajor - 0.25, rmajor + 0.25, rmajor, rmajor, rmajor],
[0, 0, 0, 0.25, -0.25],
color="black",
)
def cumulative_radial_build(section, mfile_data, scan):
"""Function for calculating the cumulative radial build up to and
including the given section.
Arguments:
section --> section of the radial build to go up to
mfile_data --> MFILE data object
scan --> scan number to use
Returns:
cumulative_build --> cumulative radial build up to section given
"""
complete = False
cumulative_build = 0
for item in RADIAL_BUILD:
if item == "rminori" or item == "rminoro":
cumulative_build += mfile_data.data["rminor"].get_scan(scan)
elif item == "vvblgapi" or item == "vvblgapo":
cumulative_build += mfile_data.data["dr_shld_blkt_gap"].get_scan(scan)
elif "dr_vv_inboard" in item:
cumulative_build += mfile_data.data["dr_vv_inboard"].get_scan(scan)
elif "dr_vv_outboard" in item:
cumulative_build += mfile_data.data["dr_vv_outboard"].get_scan(scan)
else:
cumulative_build += mfile_data.data[item].get_scan(scan)
if item == section:
complete = True
break
if complete is False:
print("radial build parameter ", section, " not found")
return cumulative_build
def cumulative_radial_build2(section, mfile_data, scan):
"""Function for calculating the cumulative radial build up to and
including the given section.
Arguments:
section --> section of the radial build to go up to
mfile_data --> MFILE data object
scan --> scan number to use
Returns:
cumulative_build --> cumulative radial build up to and including
section given
previous --> cumulative radial build up to section given
"""
cumulative_build = 0
build = 0
for item in RADIAL_BUILD:
if item == "rminori" or item == "rminoro":
build = mfile_data.data["rminor"].get_scan(scan)
elif item == "vvblgapi" or item == "vvblgapo":
build = mfile_data.data["dr_shld_blkt_gap"].get_scan(scan)
elif "dr_vv_inboard" in item:
build = mfile_data.data["dr_vv_inboard"].get_scan(scan)
elif "dr_vv_outboard" in item:
build = mfile_data.data["dr_vv_outboard"].get_scan(scan)
else:
build = mfile_data.data[item].get_scan(scan)
cumulative_build += build
if item == section:
break
previous = cumulative_build - build
return (cumulative_build, previous)
def poloidal_cross_section(axis, mfile_data, scan, demo_ranges, colour_scheme):
"""Function to plot poloidal cross-section
Arguments:
axis --> axis object to add plot to
mfile_data --> MFILE data object
scan --> scan number to use
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()
plot_vacuum_vessel_and_divertor(axis, mfile_data, scan, colour_scheme)
plot_shield(axis, mfile_data, scan, colour_scheme)
plot_blanket(axis, mfile_data, scan, colour_scheme)
plot_firstwall(axis, mfile_data, scan, colour_scheme)
plot_plasma(axis, mfile_data, scan, colour_scheme)
plot_centre_cross(axis, mfile_data, scan)
plot_cryostat(axis, mfile_data, scan, colour_scheme)
plot_tf_coils(axis, mfile_data, scan, colour_scheme)
plot_pf_coils(axis, mfile_data, scan, colour_scheme)
# Ranges
# ---
# DEMO : Fixed ranges for comparison
if demo_ranges:
axis.set_ylim([-15, 15])
axis.set_xlim([0, 20])
# Adapatative ranges
else:
axis.set_xlim([0, axis.get_xlim()[1]])
# ---
def plot_main_power_flow(
axis: plt.Axes, mfile_data: mf.MFile, scan: int, fig: plt.Figure
) -> None:
"""
Plots the main power flow diagram for the fusion reactor, including plasma, heating and current drive,
first wall, blanket, vacuum vessel, divertor, coolant pumps, turbine, generator, and auxiliary systems.
Annotates the diagram with power values and draws arrows to indicate power flows.
Args:
axis (plt.Axes): The matplotlib axis object to plot on.
mfile_data (mf.MFile): The MFILE data object containing power flow parameters.
scan (int): The scan number to use for extracting data.
fig (plt.Figure): The matplotlib figure object for additional annotations.
"""
axis.text(
0.05,
0.95,
"* Components do not represent the design",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=11,
)
# ==========================================
# Plasma
# ===========================================
# Load the plasma image
with resources.path("process.io", "plasma.png") as img_path:
plasma = mpimg.imread(img_path.open("rb"))
# Display the plasma image over the figure, not the axes
new_ax = axis.inset_axes(
[-0.15, 0.6, 0.45, 0.45], transform=axis.transAxes, zorder=1
)
new_ax.imshow(plasma)
new_ax.axis("off")
# Add fusion power to plasma
axis.text(
0.22,
0.75,
"$P_{{fus}}$\n"
f"{mfile_data.data['p_fusion_total_mw'].get_scan(scan):.2f} MW",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=11,
)
# Load the neutron image
with resources.path("process.io", "neutron.png") as img_path:
neutron = mpimg.imread(img_path.open("rb"))
new_ax = axis.inset_axes(
[0.2, 0.85, 0.03, 0.03], transform=axis.transAxes, zorder=10
)
new_ax.imshow(neutron)
new_ax.axis("off")
# Add lost alpha power
axis.text(
0.22,
0.81,
"$P_{\\alpha,{loss}}$\n"
f"{mfile_data.data['p_fw_alpha_mw'].get_scan(scan):,.2f} MW",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=11,
)
# Add radiation power to plasma
axis.text(
0.22,
0.69,
f"$P_{{{{rad}}}}$\n{mfile_data.data['p_plasma_rad_mw'].get_scan(scan):,.2f} MW",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=11,
)
# Add photon image to plasma
axis.text(
0.34,
0.71,
"$\\gamma$",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=12,
)
# Draw from gamma arrow bend towards divertor
axis.annotate(
"",
xy=(0.35, 0.55),
xytext=(0.35, 0.695),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "blue",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Add separatrix power to plasma
axis.text(
0.22,
0.63,
f"$P_{{{{sep}}}}$\n{mfile_data.data['p_plasma_separatrix_mw'].get_scan(scan):,.2f} MW",
transform=fig.transFigure,
horizontalalignment="left",
verticalalignment="bottom",
zorder=2,
fontsize=11,
)
# Draw from separatrix power to arrow bend
axis.annotate(
"",
xy=(0.3725, 0.65),
xytext=(0.3, 0.65),
xycoords=fig.transFigure,
arrowprops={
"color": "pink",
"arrowstyle": "-", # No arrow head
"linewidth": 2.0,
},
)
# Draw from separatrix arrow bend to the divertor
axis.annotate(
"",
xy=(0.37, 0.55),
xytext=(0.37, 0.65),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3", # solid filled head
"color": "pink",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Draw neutron arrow from plasma
axis.annotate(
"",
xy=(0.95, 0.76),
xytext=(0.31, 0.76),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "grey",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Draw arrow from main neutron arrow down to divertor
axis.annotate(
"",
xy=(0.39, 0.55),
xytext=(0.39, 0.76),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "grey",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Draw radiation arrow from plasma
axis.annotate(
"",
xy=(0.56, 0.695),
xytext=(0.3, 0.695),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "blue",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Load the alpha particle image
with resources.path("process.io", "alpha_particle.png") as img_path:
alpha = mpimg.imread(img_path.open("rb"))
# Display the alpha particle image over the figure, not the axes
new_ax = axis.inset_axes(
[0.16, 0.95, 0.025, 0.025], transform=axis.transAxes, zorder=10
)
new_ax.imshow(alpha)
new_ax.axis("off")
# Hide the axes for a cleaner look
axis.axis("off")
# Draw alpha particle arrow from plasma
axis.annotate(
"",
xy=(0.56, 0.83),
xytext=(0.3, 0.83),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "red",
"linewidth": 2.0,
"zorder": 5,
"fill": True,
},
)
# Plot neutron power from plasma to box
axis.text(
0.37,
0.775,
f"$P_{{\\text{{neutron}}}}$:\n{mfile_data.data['p_neutron_total_mw'].get_scan(scan):,.2f} MW",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "grey",
"alpha": 0.8,
"linewidth": 2,
},
)
# ===========================================
# =========================================
# Heating and current drive systems
# =========================================
# Add HCD primary injected power
axis.text(
0.0725,
0.83,
f"$P_{{\\text{{HCD,primary}}}}$: {mfile_data.data['p_hcd_primary_injected_mw'].get_scan(scan) + mfile_data.data['p_hcd_primary_extra_heat_mw'].get_scan(scan):.2f} MW",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightyellow",
"alpha": 1.0,
"linewidth": 2,
},
)
# Add HCD secondary injected power
axis.text(
0.0725,
0.725,
f"$P_{{\\text{{HCD,secondary}}}}$: {mfile_data.data['p_hcd_secondary_injected_mw'].get_scan(scan) + mfile_data.data['p_hcd_secondary_extra_heat_mw'].get_scan(scan):.2f} MW",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightyellow",
"alpha": 1.0,
"linewidth": 2,
},
)
# Load the HCD injector image
with resources.path("process.io", "hcd_injector.png") as img_path:
hcd_injector_1 = hcd_injector_2 = mpimg.imread(img_path.open("rb"))
# Display the injector image over the figure, not the axes
new_ax = axis.inset_axes(
[-0.2, 0.8, 0.15, 0.15], transform=axis.transAxes, zorder=10
)
new_ax.imshow(hcd_injector_1)
new_ax.axis("off")
new_ax = axis.inset_axes(
[-0.2, 0.5, 0.15, 0.5], transform=axis.transAxes, zorder=10
)
new_ax.imshow(hcd_injector_2)
new_ax.axis("off")
# Draw a dashed line with an arrow tip coming from the left of each injector
for y in [0.875, 0.75]:
axis.annotate(
"",
xy=(-0.2, y),
xytext=(-0.28, y),
xycoords=axis.transAxes,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "black",
"linewidth": 1.5,
"zorder": 11,
},
annotation_clip=False,
)
# Plot line from HCD power supply to bend for injected
axis.plot(
[-0.28, -0.28],
[0.875, 0.5],
transform=axis.transAxes,
color="black",
linewidth=1.5,
zorder=3,
clip_on=False,
)
# Plot the HCD power supply box
axis.text(
0.04,
0.45,
"\n\nH&CD Power Supply\n\n",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightyellow",
"alpha": 1.0,
"linewidth": 2,
},
zorder=4,
)
# Draw arrow from HCD box going to primary HCD losses
axis.annotate(
"",
xy=(0.2, 0.5),
xytext=(0.1, 0.5),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.2",
"color": "black",
"linestyle": "--",
"linewidth": 1.5,
"zorder": 5,
"fill": True,
},
)
# Plot electric power losses for secondary HCD
axis.text(
0.2,
0.435,
f"$P_{{\\text{{secondary,loss}}}}$:\n{mfile_data.data['p_hcd_secondary_electric_mw'].get_scan(scan) * (1.0 - mfile_data.data['eta_hcd_secondary_injector_wall_plug'].get_scan(scan)):.2f} MWe",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightblue",
"alpha": 1.0,
"linewidth": 2,
"linestyle": "dashed",
},
)
# Draw an arrow from HCD secondary losses to the total secondary heat power
axis.annotate(
"",
xy=(0.25, 0.3),
xytext=(0.25, 0.43),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "black",
"linewidth": 1.5,
"zorder": 5,
"fill": True,
"linestyle": "--",
},
)
# Draw an arrow from HCD primary losses bend to the total secondary heat power
axis.annotate(
"",
xy=(0.28, 0.3),
xytext=(0.28, 0.5),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "black",
"linewidth": 1.5,
"zorder": 5,
"fill": True,
"linestyle": "--",
},
)
# Draw line from HCD primary losses to the arrow bend
axis.annotate(
"",
xy=(0.26, 0.5),
xytext=(0.28, 0.5),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-",
"color": "black",
"linestyle": "--",
"linewidth": 1.5,
"zorder": 5,
"fill": True,
},
)
# Draw arrow frim HCD power supply to secondary HCD losses
axis.annotate(
"",
xy=(0.2, 0.46),
xytext=(0.1, 0.46),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.2",
"color": "black",
"linestyle": "--",
"linewidth": 1.5,
"zorder": 5,
"fill": True,
},
)
# Plot electric power losses for primary HCD
axis.text(
0.2,
0.485,
f"$P_{{\\text{{primary,loss}}}}$:\n{mfile_data.data['p_hcd_primary_electric_mw'].get_scan(scan) * (1.0 - mfile_data.data['eta_hcd_primary_injector_wall_plug'].get_scan(scan)):.2f} MWe",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightblue",
"alpha": 1.0,
"linewidth": 2,
"linestyle": "dashed",
},
)
# Draw arrow from HCD primary electric box to HCD power supply box
axis.annotate(
"",
xy=(0.06, 0.45),
xytext=(0.06, 0.38),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "->",
"color": "black",
"linewidth": 1.5,
"zorder": 5,
},
)
# Draw arrow from HCD secondary electric box to HCD power supply box
axis.annotate(
"",
xy=(0.12, 0.45),
xytext=(0.12, 0.38),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "->",
"color": "black",
"linewidth": 1.5,
"zorder": 5,
},
)
# Plot HCD secondary losses box
axis.text(
0.12,
0.35,
f"$P_{{\\text{{secondary}}}}$:\n{mfile_data.data['p_hcd_secondary_electric_mw'].get_scan(scan):.2f} MWe \n$\\eta$: {mfile_data.data['eta_hcd_secondary_injector_wall_plug'].get_scan(scan):.2f}",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightyellow",
"alpha": 1.0,
"linewidth": 2,
},
)
# Plot HCD primary electric box
axis.text(
0.025,
0.35,
f"$P_{{\\text{{primary}}}}$:\n{mfile_data.data['p_hcd_primary_electric_mw'].get_scan(scan):.2f} MWe\n$\\eta$: {mfile_data.data['eta_hcd_primary_injector_wall_plug'].get_scan(scan):.2f}",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightyellow",
"alpha": 1.0,
"linewidth": 2,
},
)
# =============================================
# =============================================
# Low grade heat total
# =============================================
# Plot box of total low grade secondary heat
axis.text(
0.325,
0.225,
f"\n\nTotal Low Grade Secondary Heat\n\n {mfile_data.data['p_plant_secondary_heat_mw'].get_scan(scan):,.2f} MWth",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="center",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "lightblue",
"alpha": 1.0,
"linewidth": 2,
"linestyle": "dashed",
},
zorder=4,
)
# =============================================
# ==========================================
# Power conversion systems
# ===========================================
# Load the turbine image
with resources.path("process.io", "turbine.png") as img_path:
turbine = mpimg.imread(img_path.open("rb"))
# Display the turbine image over the figure, not the axes
new_ax = axis.inset_axes(
[1.1, 0.0, 0.15, 0.15], transform=axis.transAxes, zorder=10
)
new_ax.imshow(turbine)
new_ax.axis("off")
# Plot the total primary thermal power box
axis.text(
0.9,
0.25,
f"$P_{{\\text{{primary,thermal}}}}$:\n{mfile_data.data['p_plant_primary_heat_mw'].get_scan(scan):,.2f} MW \n$\\eta_{{\\text{{turbine}}}}$: {mfile_data.data['eta_turbine'].get_scan(scan):.3f}",
fontsize=9,
verticalalignment="bottom",
horizontalalignment="left",
transform=fig.transFigure,
bbox={
"boxstyle": "round",
"facecolor": "orange",
"alpha": 1.0,
"linewidth": 2,
},
)
# Draw arrow from bend to turbine inlet
axis.annotate(
"",
xy=(0.925, 0.165),
xytext=(0.96, 0.165),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-|>,head_length=1,head_width=0.3",
"color": "orange",
"linewidth": 3.0,
"zorder": 5,
"fill": True,
},
)
# Total primary thermal to turbine inlet line bend
axis.annotate(
"",
xy=(0.96, 0.245),
xytext=(0.96, 0.1625),
xycoords=fig.transFigure,
arrowprops={
"arrowstyle": "-",
"color": "orange",
"linewidth": 3.0,
"zorder": 5,
"fill": True,
},
)
# Load the generator image
with resources.path("process.io", "generator.png") as img_path:
generator = mpimg.imread(img_path.open("rb"))
# Display the generator image over the figure, not the axes
new_ax = axis.inset_axes(
[0.96, 0.0, 0.15, 0.15], transform=axis.transAxes, zorder=10
)
new_ax.imshow(generator)
new_ax.axis("off")
# Generator to gross electric power
axis.annotate(
"",
xy=(0.745, 0.17),
xytext=(0.79, 0.17),