Skip to content

power

Power

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

    def pfpwr(self, output: bool):
        """PF coil power supply requirements

        outfile : input integer : output file unit
        iprint : input integer : switch for writing to output (1=yes)
        This routine calculates the MVA, power and energy requirements
        for the PF coil systems.  Units are MW and MVA for power terms.
        The routine checks at the beginning of the flattop for the
        peak MVA, and at the end of flattop for the peak stored energy.
        The reactive (inductive) components use waves to calculate the
        <I>dI/dt</I> at the time periods.
        None

        Parameters
        ----------
        output: bool

        """
        powpfii = np.zeros((pfcoil_variables.NGC2,))
        cktr = np.zeros((pfcoil_variables.NGC2,))
        pfcr = np.zeros((pfcoil_variables.NGC2,))
        albusa = np.zeros((pfcoil_variables.NGC2,))
        pfbusr = np.zeros((pfcoil_variables.NGC2,))
        pfcr = np.zeros((pfcoil_variables.NGC2,))
        cktr = np.zeros((pfcoil_variables.NGC2,))
        rcktvm = np.zeros((pfcoil_variables.NGC2,))
        rcktpm = np.zeros((pfcoil_variables.NGC2,))
        vpfi = np.zeros((pfcoil_variables.NGC2,))
        psmva = np.zeros((pfcoil_variables.NGC2,))
        poloidalenergy = np.zeros((6,))
        inductxcurrent = np.zeros((6,))
        pfdissipation = np.zeros((5,))

        #  Bus length
        pfbusl = 8.0e0 * physics_variables.rmajor + 140.0e0

        #  Find power requirements for PF coils at times_variables.t_pulse_cumulative(ktim)

        #  PF coil resistive power requirements
        #  Bussing losses assume aluminium bussing with 100 A/cm**2
        ic = -1
        ngrpt = pfcoil_variables.n_pf_coil_groups
        if build_variables.iohcl != 0:
            ngrpt = ngrpt + 1

        pf_power_variables.srcktpm = 0.0e0
        pfbuspwr = 0.0e0

        for ig in range(ngrpt):
            ic = ic + pfcoil_variables.n_pf_coils_in_group[ig]

            #  Section area of aluminium bussing for circuit (cm**2)
            #  pfcoil_variables.c_pf_coil_turn_peak_input : max current per turn of coil (A)
            albusa[ig] = abs(pfcoil_variables.c_pf_coil_turn_peak_input[ic]) / 100.0e0

            #  Resistance of bussing for circuit (ohm)
            #  pfbusl : bus length for each PF circuit (m)
            #  pfbusr[ig] = 1.5e0 * 2.62e-4 * pfbusl / albusa[ig]
            #  I have removed the fudge factor of 1.5 but included it in the value of rhopfbus
            pfbusr[ig] = pfcoil_variables.rhopfbus * pfbusl / (albusa[ig] / 10000)

            #  Total PF coil resistance (during burn)
            #  pfcoil_variables.c_pf_cs_coils_peak_ma : maximum current in coil (A)
            pfcr[ig] = (
                pfcoil_variables.rho_pf_coil
                * 2.0e0
                * np.pi
                * pfcoil_variables.r_pf_coil_middle[ic]
                * abs(
                    pfcoil_variables.j_pf_coil_wp_peak[ic]
                    / (
                        (1.0e0 - pfcoil_variables.f_a_pf_coil_void[ic])
                        * 1.0e6
                        * pfcoil_variables.c_pf_cs_coils_peak_ma[ic]
                    )
                )
                * pfcoil_variables.n_pf_coil_turns[ic] ** 2
                * pfcoil_variables.n_pf_coils_in_group[ig]
            )

            cktr[ig] = pfcr[ig] + pfbusr[ig]  # total resistance of circuit (ohms)
            cptburn = (
                pfcoil_variables.c_pf_coil_turn_peak_input[ic]
                * pfcoil_variables.c_pf_cs_coil_pulse_end_ma[ic]
                / pfcoil_variables.c_pf_cs_coils_peak_ma[ic]
            )
            rcktvm[ig] = abs(cptburn) * cktr[ig]  # peak resistive voltage (V)
            rcktpm[ig] = 1.0e-6 * rcktvm[ig] * abs(cptburn)  # peak resistive power (MW)

            #  Compute the sum of resistive power in the PF circuits, kW
            pfbuspwr = pfbuspwr + 1.0e-3 * pfbusr[ig] * cptburn**2
            pf_power_variables.srcktpm = pf_power_variables.srcktpm + 1.0e3 * rcktpm[ig]

        #  Inductive MVA requirements, and stored energy
        delktim = times_variables.t_plant_pulse_plasma_current_ramp_up

        #  PF system (including Central Solenoid solenoid) inductive MVA requirements
        #  pfcoil_variables.c_pf_coil_turn(i,j) : current per turn of coil i at (end) time period j (A)
        powpfi = 0.0e0
        powpfr = 0.0e0
        powpfr2 = 0.0e0

        #  pfcoil_variables.n_pf_cs_plasma_circuits : total number of PF coils (including Central Solenoid and plasma)
        #          plasma is #n_pf_cs_plasma_circuits, and Central Solenoid is #(pfcoil_variables.n_pf_cs_plasma_circuits-1)
        #  pfcoil_variables.ind_pf_cs_plasma_mutual(i,j) : mutual inductance between coil i and j
        for i in range(pfcoil_variables.n_pf_cs_plasma_circuits):
            powpfii[i] = 0.0e0
            vpfi[i] = 0.0e0

        jpf = -1
        poloidalenergy[:] = 0.0e0
        for jjpf in range(ngrpt):  # Loop over all groups of PF coils.
            for _jjpf2 in range(
                pfcoil_variables.n_pf_coils_in_group[jjpf]
            ):  # Loop over all coils in each group
                jpf = jpf + 1
                inductxcurrent[:] = 0.0e0
                for ipf in range(pfcoil_variables.n_pf_cs_plasma_circuits):
                    #  Voltage in circuit jpf due to change in current from circuit ipf
                    vpfij = (
                        pfcoil_variables.ind_pf_cs_plasma_mutual[jpf, ipf]
                        * (
                            pfcoil_variables.c_pf_coil_turn[ipf, 2]
                            - pfcoil_variables.c_pf_coil_turn[ipf, 1]
                        )
                        / delktim
                    )

                    #  Voltage in circuit jpf at time, times_variables.t_pulse_cumulative(3), due to changes in coil currents
                    vpfi[jpf] = vpfi[jpf] + vpfij

                    #  MVA in circuit jpf at time, times_variables.t_pulse_cumulative(3) due to changes in current
                    powpfii[jpf] = (
                        powpfii[jpf]
                        + vpfij * pfcoil_variables.c_pf_coil_turn[jpf, 2] / 1.0e6
                    )

                    # Term used for calculating stored energy at each time
                    for time in range(6):
                        inductxcurrent[time] = (
                            inductxcurrent[time]
                            + pfcoil_variables.ind_pf_cs_plasma_mutual[jpf, ipf]
                            * pfcoil_variables.c_pf_coil_turn[ipf, time]
                        )

                    # engx = engx + pfcoil_variables.ind_pf_cs_plasma_mutual(jpf,ipf)*pfcoil_variables.c_pf_coil_turn(ipf,5)

                #  Stored magnetic energy of the poloidal field at each time
                # 'time' is the time INDEX.  't_pulse_cumulative' is the time.
                for time in range(6):
                    poloidalenergy[time] = (
                        poloidalenergy[time]
                        + 0.5e0
                        * inductxcurrent[time]
                        * pfcoil_variables.c_pf_coil_turn[jpf, time]
                    )

                #   do time = 1,5
                #     # Mean rate of change of stored energy between time and time+1
                #     if(abs(times_variables.t_pulse_cumulative(time+1)-times_variables.t_pulse_cumulative(time)).gt.1.0e0) :
                #         pf_power_variables.poloidalpower(time) = (poloidalenergy(time+1)-poloidalenergy(time)) / (times_variables.t_pulse_cumulative(time+1)-times_variables.t_pulse_cumulative(time))
                #     else:
                #         # Flag when an interval is small or zero MDK 30/11/16
                #         pf_power_variables.poloidalpower(time) = 9.9e9
                #

                #   end do
                #   #engxpc = 0.5e0 * engx * pfcoil_variables.c_pf_coil_turn(jpf,5)
                #   #ensxpf = ensxpf + engxpc

                #  Resistive power in circuits at times times_variables.t_pulse_cumulative(3) and times_variables.t_pulse_cumulative(5) respectively (MW)
                powpfr = (
                    powpfr
                    + pfcoil_variables.n_pf_coil_turns[jpf]
                    * pfcoil_variables.c_pf_coil_turn[jpf, 2]
                    * cktr[jjpf]
                    / 1.0e6
                )
                powpfr2 = (
                    powpfr2
                    + pfcoil_variables.n_pf_coil_turns[jpf]
                    * pfcoil_variables.c_pf_coil_turn[jpf, 4]
                    * cktr[jjpf]
                    / 1.0e6
                )
                powpfi = powpfi + powpfii[jpf]

        for time in range(5):
            # Stored magnetic energy of the poloidal field at each time
            # 'time' is the time INDEX.  't_pulse_cumulative' is the time.
            # Mean rate of change of stored energy between time and time+1
            if (
                abs(
                    times_variables.t_pulse_cumulative[time + 1]
                    - times_variables.t_pulse_cumulative[time]
                )
                > 1.0e0
            ):
                pf_power_variables.poloidalpower[time] = (
                    poloidalenergy[time + 1] - poloidalenergy[time]
                ) / (
                    times_variables.t_pulse_cumulative[time + 1]
                    - times_variables.t_pulse_cumulative[time]
                )
            else:
                # Flag when an interval is small or zero MDK 30/11/16
                pf_power_variables.poloidalpower[time] = 9.9e9

            # Electrical energy dissipated in PFC power supplies as they increase or decrease the poloidal field energy
            # This assumes that the energy storage in the PFC power supply is lossless and that currents
            # in the coils can be varied without loss when there is no change in the energy in the poloidal field.
            # Energy is dissipated only when energy moves into or out of the store in the power supply.
            # Issue #713
            pfdissipation[time] = abs(
                poloidalenergy[time + 1] - poloidalenergy[time]
            ) * (1.0e0 / pfcoil_variables.etapsu - 1.0e0)

        # Mean power dissipated
        # The flat top duration (time 4 to 5) is the denominator, as this is the time when electricity is generated.
        if (
            times_variables.t_pulse_cumulative[4] - times_variables.t_pulse_cumulative[3]
            > 1.0e0
        ):
            pfpower = sum(pfdissipation[:]) / (
                times_variables.t_pulse_cumulative[4]
                - times_variables.t_pulse_cumulative[3]
            )
        else:
            # Give up when an interval is small or zero.
            pfpower = 0.0e0

        pfpowermw = pfpower / 1.0e6

        #  Compute the maximum stored energy and the maximum dissipative
        #  energy in all the PF circuits over the entire cycle time, MJ
        # ensxpfm = 1.0e-6 * ensxpf
        pf_power_variables.ensxpfm = 1.0e-6 * max(poloidalenergy)
        # Peak absolute rate of change of stored energy in poloidal field (MW)
        pf_power_variables.peakpoloidalpower = (
            max(abs(pf_power_variables.poloidalpower)) / 1.0e6
        )

        #  Maximum total MVA requirements
        heat_transport_variables.peakmva = max((powpfr + powpfi), powpfr2)

        pf_power_variables.vpfskv = 20.0e0
        pf_power_variables.pfckts = (
            pfcoil_variables.n_pf_cs_plasma_circuits - 2
        ) + 6.0e0
        pf_power_variables.spfbusl = pfbusl * pf_power_variables.pfckts
        pf_power_variables.acptmax = 0.0e0
        pf_power_variables.spsmva = 0.0e0

        for jpf in range(pfcoil_variables.n_pf_cs_plasma_circuits - 1):
            #  Power supply MVA for each PF circuit
            psmva[jpf] = 1.0e-6 * abs(
                vpfi[jpf] * pfcoil_variables.c_pf_coil_turn_peak_input[jpf]
            )

            #  Sum of the power supply MVA of the PF circuits
            pf_power_variables.spsmva = pf_power_variables.spsmva + psmva[jpf]

            #  Average of the maximum currents in the PF circuits, kA
            pf_power_variables.acptmax = (
                pf_power_variables.acptmax
                + 1.0e-3
                * abs(pfcoil_variables.c_pf_coil_turn_peak_input[jpf])
                / pf_power_variables.pfckts
            )

        #  PF wall plug power dissipated in power supply for ohmic heating (MW)
        #  This is additional to that required for moving stored energy around
        # p_pf_electric_supplies_mw = physics_variables.p_plasma_ohmic_mw / pfcoil_variables.etapsu
        wall_plug_ohmicmw = physics_variables.p_plasma_ohmic_mw * (
            1.0e0 / pfcoil_variables.etapsu - 1.0e0
        )
        # Total mean wall plug power dissipated in PFC and CS power supplies.  Issue #713
        pfcoil_variables.p_pf_electric_supplies_mw = wall_plug_ohmicmw + pfpowermw

        #  Output Section
        if output == 0:
            return

        po.oheadr(self.outfile, "PF Coils and Central Solenoid: Power and Energy")
        po.ovarre(
            self.outfile,
            "Number of PF coil circuits",
            "(pfckts)",
            pf_power_variables.pfckts,
        )
        po.ovarre(
            self.outfile,
            "Sum of PF power supply ratings (MVA)",
            "(spsmva)",
            pf_power_variables.spsmva,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total PF coil circuit bus length (m)",
            "(spfbusl)",
            pf_power_variables.spfbusl,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total PF coil bus resistive power (kW)",
            "(pfbuspwr)",
            pfbuspwr,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total PF coil resistive power (kW)",
            "(srcktpm)",
            pf_power_variables.srcktpm,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Maximum PF coil voltage (kV)",
            "(vpfskv)",
            pf_power_variables.vpfskv,
        )
        po.ovarre(
            self.outfile,
            "Efficiency of transfer of PF stored energy into or out of storage",
            "(etapsu)",
            pfcoil_variables.etapsu,
        )
        po.ocmmnt(
            self.outfile,
            "(Energy is dissipated in PFC power supplies only when total PF energy increases or decreases.)",
        )

        po.ovarre(
            self.outfile,
            "Maximum stored energy in poloidal field (MJ)",
            "(ensxpfm)",
            pf_power_variables.ensxpfm,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Peak absolute rate of change of stored energy in poloidal field (MW)",
            "(peakpoloidalpower)",
            pf_power_variables.peakpoloidalpower,
            "OP ",
        )

        if (numerics.ioptimz > 0) and (numerics.active_constraints[65]):
            po.ovarre(
                self.outfile,
                "Max permitted abs rate of change of stored energy in poloidal field (MW)",
                "maxpoloidalpower",
                pf_power_variables.maxpoloidalpower,
            )

        if any(poloidalenergy < 0.0e0):
            po.oheadr(self.outfile, "ERROR Negative stored energy in poloidal field")
            logger.error(f"{'ERROR Negative stored energy in poloidal field'}")

        po.ocmmnt(self.outfile, "Energy stored in poloidal magnetic field :")
        po.oblnkl(self.outfile)

        # write(self.outfile,50)(times_variables.t_pulse_cumulative(time),time=1,6)

    def acpow(self, output: bool):
        """AC power requirements


        outfile : input integer : output file unit
        iprint : input integer : switch for writing to output (1=yes)
        The routine was drastically shortened on 23/01/90 (ORNL) from the
        original TETRA routine to provide only the total power needs for
        the plant. Included in STORAC in January 1992 by P.C. Shipe.
        None

        Parameters
        ----------
        output: bool

        """
        ptfmw = heat_transport_variables.p_tf_electric_supplies_mw
        ppfmw = 1.0e-3 * pf_power_variables.srcktpm
        if pf_power_variables.i_pf_energy_storage_source == 2:
            ppfmw = ppfmw + heat_transport_variables.peakmva

        #  Power to plasma heating supplies, MW
        pheatingmw = (
            heat_transport_variables.p_hcd_electric_total_mw
        )  # Should be zero if i_plasma_ignited==1

        #  Power to cryogenic comp. motors, MW
        crymw = heat_transport_variables.p_cryo_plant_electric_mw

        #  Power to divertor coil supplies, MW
        bdvmw = 0.0e0

        #  Total pulsed power system load, MW
        heat_transport_variables.pacpmw = (
            ppfmw
            + bdvmw
            + ptfmw
            + crymw
            + heat_transport_variables.vachtmw
            + heat_transport_variables.p_coolant_pump_elec_total_mw
            + heat_transport_variables.p_tritium_plant_electric_mw
            + pheatingmw
        )

        #  Add contribution from motor-generator flywheels if these are part of
        #  the PF coil energy storage system
        if pf_power_variables.i_pf_energy_storage_source != 2:
            heat_transport_variables.pacpmw = (
                heat_transport_variables.pacpmw + heat_transport_variables.fmgdmw
            )

        # Estimate of the total low voltage power, MW
        # MDK No idea what this is - especially the last term
        # It is used in the old cost routine, so I will leave it in place.
        heat_transport_variables.tlvpmw = (
            heat_transport_variables.p_plant_electric_base_total_mw
            + heat_transport_variables.p_tritium_plant_electric_mw
            + heat_transport_variables.p_coolant_pump_elec_total_mw
            + heat_transport_variables.vachtmw
            + 0.5e0 * (crymw + ppfmw)
        )

        if output == 0:
            return

        #  Output section
        # po.oheadr(self.outfile,'AC Power')
        po.oheadr(self.outfile, "Electric Power Requirements")
        po.ovarre(self.outfile, "Divertor coil power supplies (MW)", "(bdvmw)", bdvmw)
        po.ovarre(self.outfile, "Cryoplant electric power (MW)", "(crymw)", crymw, "OP ")
        # po.ovarre(self.outfile,'Heat removed from cryogenic coils (MWth)','(helpow/1.0e6)',helpow/1.0e6)
        # po.ovarre(self.outfile,'MGF (motor-generator flywheel) units (MW)', '(fmgdmw)',fmgdmw)
        # po.ovarin(self.outfile,'Primary coolant pumps (MW)', '(i_blkt_coolant_type)',i_blkt_coolant_type)
        po.ovarre(
            self.outfile,
            "Primary coolant pumps (MW)",
            "(p_coolant_pump_elec_total_mw..)",
            heat_transport_variables.p_coolant_pump_elec_total_mw,
            "OP ",
        )

        po.ovarre(self.outfile, "PF coil power supplies (MW)", "(ppfmw)", ppfmw, "OP ")
        # po.ovarre(self.outfile,'Power/floor area (kW/m2)','(pkwpm2)',pkwpm2)
        po.ovarre(self.outfile, "TF coil power supplies (MW)", "(ptfmw)", ptfmw, "OP ")
        po.ovarre(
            self.outfile,
            "Plasma heating supplies (MW)",
            "(pheatingmw)",
            pheatingmw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Tritium processing (MW)",
            "(p_tritium_plant_electric_mw..)",
            heat_transport_variables.p_tritium_plant_electric_mw,
        )
        po.ovarre(
            self.outfile,
            "Vacuum pumps  (MW)",
            "(vachtmw..)",
            heat_transport_variables.vachtmw,
        )

        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total pulsed power (MW)",
            "(pacpmw)",
            heat_transport_variables.pacpmw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total base power required at all times (MW)",
            "(p_plant_electric_base_total_mw)",
            heat_transport_variables.p_plant_electric_base_total_mw,
            "OP ",
        )
        # MDK Remove this output: no idea what this is
        # po.ovarre(self.outfile,'Total low voltage power (MW)','(tlvpmw)',tlvpmw)

    def component_thermal_powers(self):
        """Calculates the first part of the heat transport
        and plant power balance constituents
        This routine calculates the first part of the heat transport
        and plant power balance constituents.
        None
        """
        if int(fwbs_variables.i_p_coolant_pumping) not in (2, 3):
            primary_pumping_variables.p_fw_blkt_coolant_pump_mw = (
                heat_transport_variables.p_fw_coolant_pump_mw
                + heat_transport_variables.p_blkt_coolant_pump_mw
            )

        #  Account for pump electrical inefficiencies. The coolant pumps are not assumed to be
        #  100% efficient so the electric power to run them is greater than the power deposited
        #  in the coolant.  The difference should be lost as secondary heat.

        power_variables.p_fw_blkt_coolant_pump_elec_mw = (
            primary_pumping_variables.p_fw_blkt_coolant_pump_mw
            / fwbs_variables.eta_coolant_pump_electric
        )
        power_variables.p_shld_coolant_pump_elec_mw = (
            heat_transport_variables.p_shld_coolant_pump_mw
            / fwbs_variables.eta_coolant_pump_electric
        )
        power_variables.p_div_coolant_pump_elec_mw = (
            heat_transport_variables.p_div_coolant_pump_mw
            / fwbs_variables.eta_coolant_pump_electric
        )

        # Secondary breeder coolant loop. Should return zero if not used.
        power_variables.p_blkt_breeder_pump_elec_mw = (
            heat_transport_variables.p_blkt_breeder_pump_mw
            / fwbs_variables.eta_coolant_pump_electric
        )

        # Total mechanical pump power needed (deposited in coolant)
        power_variables.p_coolant_pump_total_mw = (
            primary_pumping_variables.p_fw_blkt_coolant_pump_mw
            + heat_transport_variables.p_blkt_breeder_pump_mw
            + heat_transport_variables.p_shld_coolant_pump_mw
            + heat_transport_variables.p_div_coolant_pump_mw
        )

        # Minimum total electrical power for primary coolant pumps (MW)
        heat_transport_variables.p_coolant_pump_elec_total_mw = (
            power_variables.p_fw_blkt_coolant_pump_elec_mw
            + power_variables.p_blkt_breeder_pump_elec_mw
            + power_variables.p_shld_coolant_pump_elec_mw
            + power_variables.p_div_coolant_pump_elec_mw
        )

        #  Heat lost through pump power inefficiencies (MW)
        heat_transport_variables.p_coolant_pump_loss_total_mw = (
            heat_transport_variables.p_coolant_pump_elec_total_mw
            - power_variables.p_coolant_pump_total_mw
        )

        # Heat lost in power supplies for heating and current drive
        heat_transport_variables.p_hcd_electric_loss_mw = (
            heat_transport_variables.p_hcd_electric_total_mw
            - current_drive_variables.p_hcd_injected_total_mw
        )

        # Liquid metal breeder/coolant
        # Calculate fraction of blanket nuclear power deposited in liquid breeder / coolant
        if fwbs_variables.i_blkt_dual_coolant == 2:
            power_variables.p_blkt_liquid_breeder_heat_deposited_mw = (
                fwbs_variables.p_blkt_nuclear_heat_total_mw
                * fwbs_variables.f_nuc_pow_bz_liq
            ) + heat_transport_variables.p_blkt_breeder_pump_mw

        # Liquid breeder is circulated but does no cooling
        elif fwbs_variables.i_blkt_dual_coolant == 1:
            power_variables.p_blkt_liquid_breeder_heat_deposited_mw = (
                heat_transport_variables.p_blkt_breeder_pump_mw
            )

        # Liquid breeder also acts a coolant
        if int(fwbs_variables.i_blkt_dual_coolant) in [1, 2]:
            power_variables.p_fw_blkt_heat_deposited_mw = (
                fwbs_variables.p_fw_nuclear_heat_total_mw
                + fwbs_variables.p_fw_rad_total_mw
                + fwbs_variables.p_blkt_nuclear_heat_total_mw
                + heat_transport_variables.p_blkt_breeder_pump_mw
                + primary_pumping_variables.p_fw_blkt_coolant_pump_mw
                + current_drive_variables.p_beam_orbit_loss_mw
                + physics_variables.p_fw_alpha_mw
                + current_drive_variables.p_beam_shine_through_mw
            )
        else:
            # No secondary liquid metal breeder/coolant
            power_variables.p_fw_blkt_heat_deposited_mw = (
                fwbs_variables.p_fw_nuclear_heat_total_mw
                + fwbs_variables.p_fw_rad_total_mw
                + fwbs_variables.p_blkt_nuclear_heat_total_mw
                + primary_pumping_variables.p_fw_blkt_coolant_pump_mw
                + current_drive_variables.p_beam_orbit_loss_mw
                + physics_variables.p_fw_alpha_mw
                + current_drive_variables.p_beam_shine_through_mw
            )

        #  Total power deposited in first wall coolant (MW)
        power_variables.p_fw_heat_deposited_mw = (
            fwbs_variables.p_fw_nuclear_heat_total_mw
            + fwbs_variables.p_fw_rad_total_mw
            + heat_transport_variables.p_fw_coolant_pump_mw
            + current_drive_variables.p_beam_orbit_loss_mw
            + physics_variables.p_fw_alpha_mw
            + current_drive_variables.p_beam_shine_through_mw
        )

        #  Total power deposited in blanket coolant (MW)
        power_variables.p_blkt_heat_deposited_mw = (
            fwbs_variables.p_blkt_nuclear_heat_total_mw
            + heat_transport_variables.p_blkt_coolant_pump_mw
        )

        #  Total power deposited in shield coolant (MW)
        power_variables.p_shld_heat_deposited_mw = (
            fwbs_variables.p_cp_shield_nuclear_heat_mw
            + fwbs_variables.p_shld_nuclear_heat_mw
            + heat_transport_variables.p_shld_coolant_pump_mw
        )

        #  Total thermal power deposited in divertor (MW)
        power_variables.p_div_heat_deposited_mw = (
            physics_variables.p_plasma_separatrix_mw
            + (
                fwbs_variables.p_div_nuclear_heat_total_mw
                + fwbs_variables.p_div_rad_total_mw
            )
            + heat_transport_variables.p_div_coolant_pump_mw
        )

        #  Heat removal from first wall and divertor (MW) (only used in costs.f90)
        if fwbs_variables.i_p_coolant_pumping != 3:
            heat_transport_variables.p_fw_div_heat_deposited_mw = (
                power_variables.p_fw_heat_deposited_mw
                + power_variables.p_div_heat_deposited_mw
            )

        #  Thermal to electric efficiency
        heat_transport_variables.eta_turbine = self.plant_thermal_efficiency(
            heat_transport_variables.eta_turbine
        )
        heat_transport_variables.etath_liq = self.plant_thermal_efficiency_2(
            heat_transport_variables.etath_liq
        )

        #  Primary (high-grade) thermal power, available for electricity generation.  Switch heat_transport_variables.i_shld_primary_heat
        #  is 1 or 0, is user choice on whether the shield thermal power goes to primary or secondary heat
        if fwbs_variables.i_thermal_electric_conversion == 0:
            #  Primary thermal power (MW)
            heat_transport_variables.p_plant_primary_heat_mw = (
                power_variables.p_fw_blkt_heat_deposited_mw
                + heat_transport_variables.i_shld_primary_heat
                * power_variables.p_shld_heat_deposited_mw
            )
            #  Secondary thermal power deposited in divertor (MW)
            heat_transport_variables.p_div_secondary_heat_mw = (
                power_variables.p_div_heat_deposited_mw
            )
            # Divertor primary/secondary power switch: does NOT contribute to energy generation cycle
            power_variables.i_div_primary_heat = 0
        else:
            #  Primary thermal power used to generate electricity (MW)
            heat_transport_variables.p_plant_primary_heat_mw = (
                power_variables.p_fw_blkt_heat_deposited_mw
                + heat_transport_variables.i_shld_primary_heat
                * power_variables.p_shld_heat_deposited_mw
                + power_variables.p_div_heat_deposited_mw
            )
            #  Secondary thermal power deposited in divertor (MW)
            heat_transport_variables.p_div_secondary_heat_mw = 0.0e0
            # Divertor primary/secondary power switch: contributes to energy generation cycle
            power_variables.i_div_primary_heat = 1

        if abs(heat_transport_variables.p_plant_primary_heat_mw) < 1.0e-4:
            logger.error(f"{'ERROR Primary thermal power is zero or negative'}")

        # #284 Fraction of total high-grade thermal power to divertor
        power_variables.f_p_div_primary_heat = (
            power_variables.p_div_heat_deposited_mw
            / heat_transport_variables.p_plant_primary_heat_mw
        )
        # Loss in efficiency as this primary power is collecetd at very low temperature
        power_variables.delta_eta = 0.339 * power_variables.f_p_div_primary_heat

        # ===============================================
        #  Secondary thermal powers
        # ================================================

        #  Secondary thermal power deposited in shield
        heat_transport_variables.p_shld_secondary_heat_mw = (
            power_variables.p_shld_heat_deposited_mw
            * (1 - heat_transport_variables.i_shld_primary_heat)
        )

        #  Secondary thermal power lost to HCD apparatus and diagnostics
        heat_transport_variables.p_hcd_secondary_heat_mw = (
            fwbs_variables.p_fw_hcd_nuclear_heat_mw
            + fwbs_variables.p_fw_hcd_rad_total_mw
        )

        #  Number of primary heat exchangers
        heat_transport_variables.n_primary_heat_exchangers = math.ceil(
            heat_transport_variables.p_plant_primary_heat_mw / 1000.0e0
        )

    def calculate_cryo_loads(self):
        """Calculates and updates the cryogenic heat loads for the system.

        This method computes the various cryogenic heat loads, including conduction/radiation,
        nuclear heating, AC losses, and resistive losses in current leads. It also updates
        the miscellaneous allowance and total heat removal at cryogenic temperatures.
        The results are stored in the corresponding instance variables.
        """

        #  Cryogenic power
        # ---
        # Initialisation (unchanged if all coil resisitive)
        heat_transport_variables.helpow = 0.0e0
        heat_transport_variables.p_cryo_plant_electric_mw = 0.0e0
        p_tf_cryoal_cryo = 0.0e0
        tfcoil_variables.cryo_cool_req = 0.0e0

        # Superconductors TF/PF cryogenic cooling
        if tfcoil_variables.i_tf_sup == 1 or pfcoil_variables.i_pf_conductor == 0:
            # heat_transport_variables.helpow calculation
            heat_transport_variables.helpow = self.cryo(
                tfcoil_variables.i_tf_sup,
                tfcoil_variables.tfcryoarea,
                structure_variables.coldmass,
                fwbs_variables.p_tf_nuclear_heat_mw,
                pf_power_variables.ensxpfm,
                times_variables.t_plant_pulse_plasma_present,
                tfcoil_variables.c_tf_turn,
                tfcoil_variables.n_tf_coils,
            )

            # Use 13% of ideal Carnot efficiency to fit J. Miller estimate
            # Rem SK : This ITER efficiency is very low compare to the Strowbridge curve
            #          any reasons why?
            # Calculate electric power requirement for cryogenic plant at tfcoil_variables.temp_tf_cryo (MW)
            heat_transport_variables.p_cryo_plant_electric_mw = (
                1.0e-6
                * (constants.TEMP_ROOM - tfcoil_variables.temp_tf_cryo)
                / (tfcoil_variables.eff_tf_cryo * tfcoil_variables.temp_tf_cryo)
                * heat_transport_variables.helpow
            )

        # Cryogenic alumimium
        # Rem : The carnot efficiency is assumed at 40% as this is a conservative assumption since a 50%
        #       has been deduced from detailed studies
        # Rem : Nuclear heating on the outer legs assumed to be negligible
        # Rem : To be updated with 2 cooling loops for TART designs
        if tfcoil_variables.i_tf_sup == 2:
            # Heat removal power at cryogenic temperature tfcoil_variables.temp_cp_coolant_inlet (W)
            heat_transport_variables.helpow_cryal = (
                tfcoil_variables.p_cp_resistive
                + tfcoil_variables.p_tf_leg_resistive
                + tfcoil_variables.p_tf_joints_resistive
                + fwbs_variables.pnuc_cp_tf * 1.0e6
            )

            # Calculate electric power requirement for cryogenic plant at tfcoil_variables.temp_cp_coolant_inlet (MW)
            p_tf_cryoal_cryo = (
                1.0e-6
                * (constants.TEMP_ROOM - tfcoil_variables.temp_cp_coolant_inlet)
                / (tfcoil_variables.eff_tf_cryo * tfcoil_variables.temp_cp_coolant_inlet)
                * heat_transport_variables.helpow_cryal
            )

            # Add to electric power requirement for cryogenic plant (MW)
            heat_transport_variables.p_cryo_plant_electric_mw = (
                heat_transport_variables.p_cryo_plant_electric_mw + p_tf_cryoal_cryo
            )

        # Calculate cryo cooling requirement at 4.5K (kW)
        tfcoil_variables.cryo_cool_req = (
            heat_transport_variables.helpow
            * ((293 / tfcoil_variables.temp_tf_cryo) - 1)
            / ((293 / 4.5) - 1)
            + heat_transport_variables.helpow_cryal
            * ((293 / tfcoil_variables.temp_cp_coolant_inlet) - 1)
            / ((293 / 4.5) - 1)
        ) / 1.0e3

    def output_plant_thermal_powers(self):
        po.oheadr(self.outfile, "Plant Heat Transport Balance")

        po.ocmmnt(self.outfile, "First Wall : ")
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heat deposited in FW [MW]",
            "(p_fw_nuclear_heat_total_mw)",
            fwbs_variables.p_fw_nuclear_heat_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Radiation heat deposited in FW [MW]",
            "(p_fw_rad_total_mw)",
            fwbs_variables.p_fw_rad_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Lost alpha-particle heat deposited in FW [MW]",
            "(p_fw_alpha_mw)",
            physics_variables.p_fw_alpha_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutral beam shine-through heat deposited in FW [MW]",
            "(p_beam_shine_through_mw)",
            current_drive_variables.p_beam_shine_through_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutral beam orbit loss heat deposited in FW [MW]",
            "(p_beam_orbit_loss_mw)",
            current_drive_variables.p_beam_orbit_loss_mw,
        )

        po.ovarre(
            self.outfile,
            "Mechancial pumping power deposited in FW coolant [MW]",
            "(p_fw_coolant_pump_mw)",
            heat_transport_variables.p_fw_coolant_pump_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total heat deposited in FW and coolant [MW]",
            "(p_fw_heat_deposited_mw)",
            power_variables.p_fw_heat_deposited_mw,
        )
        po.oblnkl(self.outfile)

        po.ocmmnt(self.outfile, "Blanket : ")
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total neutronic nuclear heat deposited and created in Blanket(s) [MW]",
            "(p_blkt_nuclear_heat_total_mw)",
            fwbs_variables.p_blkt_nuclear_heat_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Total multiplication neutronic nuclear heat created in Blanket(s) [MW]",
            "(p_blkt_multiplication_mw)",
            fwbs_variables.p_blkt_multiplication_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutron nuclear heat multiplication factor in Blanket(s)",
            "(f_p_blkt_multiplication)",
            fwbs_variables.f_p_blkt_multiplication,
        )

        po.ovarre(
            self.outfile,
            "Mechancial pumping power deposited in Blanket(s) coolant [MW]",
            "(p_blkt_coolant_pump_mw)",
            heat_transport_variables.p_blkt_coolant_pump_mw,
        )

        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total heat deposited in Blanket(s) and coolant [MW]",
            "(p_blkt_heat_deposited_mw)",
            power_variables.p_blkt_heat_deposited_mw,
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "FW and Blanket : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Mechancial pumping power deposited in Blanket(s) and FW coolant [MW]",
            "(p_fw_blkt_coolant_pump_mw)",
            primary_pumping_variables.p_fw_blkt_coolant_pump_mw,
        )
        po.ovarre(
            self.outfile,
            "Total heat deposited in Blanket(s) and FW coolant [MW]",
            "(p_fw_blkt_heat_deposited_mw)",
            power_variables.p_fw_blkt_heat_deposited_mw,
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "VV and Shield : ")
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heat deposited in VV shield [MW]",
            "(p_shld_nuclear_heat_mw)",
            fwbs_variables.p_shld_nuclear_heat_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heat deposited in ST centrepost shield [MW]",
            "(p_cp_shield_nuclear_heat_mw)",
            fwbs_variables.p_cp_shield_nuclear_heat_mw,
        )

        po.ovarre(
            self.outfile,
            "Mechancial pumping power deposited in shield coolant(s) [MW]",
            "(p_shld_coolant_pump_mw)",
            heat_transport_variables.p_shld_coolant_pump_mw,
        )

        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total heat deposited in VV and shield coolant(s) [MW]",
            "(p_shld_heat_deposited_mw)",
            power_variables.p_shld_heat_deposited_mw,
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Divertor : ")
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Plasma separatrix power deposited in divertor [MW]",
            "(p_plasma_separatrix_mw)",
            physics_variables.p_plasma_separatrix_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heat deposited in divertor [MW]",
            "(p_div_nuclear_heat_total_mw)",
            fwbs_variables.p_div_nuclear_heat_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Radiation heat deposited in divertor [MW]",
            "(p_div_rad_total_mw)",
            fwbs_variables.p_div_rad_total_mw,
        )

        po.ovarre(
            self.outfile,
            "Mechancial pumping power deposited in divertor coolant [MW]",
            "(p_div_coolant_pump_mw)",
            heat_transport_variables.p_div_coolant_pump_mw,
        )

        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total heat deposited in divertor and coolants [MW]",
            "(p_div_heat_deposited_mw)",
            power_variables.p_div_heat_deposited_mw,
        )

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

        po.ovarre(
            self.outfile,
            "Mechanical pumping power of all coolant pumps [MW]",
            "(p_coolant_pump_total_mw)",
            power_variables.p_coolant_pump_total_mw,
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Secondary heat : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Electric power for core plant systems [MW]",
            "(p_plant_core_systems_elec_mw)",
            power_variables.p_plant_core_systems_elec_mw,
        )
        po.ovarre(
            self.outfile,
            "Wall plug losses in H&CD systems [MW]",
            "(p_hcd_electric_loss_mw)",
            heat_transport_variables.p_hcd_electric_loss_mw,
        )
        po.ovarre(
            self.outfile,
            "Total wall plug losses in coolant pump systems [MW]",
            "(p_coolant_pump_loss_total_mw)",
            heat_transport_variables.p_coolant_pump_loss_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Divertor thermal power not used for electricity production [MW]",
            "(p_div_secondary_heat_mw)",
            heat_transport_variables.p_div_secondary_heat_mw,
        )
        po.ovarre(
            self.outfile,
            "Shield thermal power not used for electricity production [MW]",
            "(p_shld_secondary_heat_mw)",
            heat_transport_variables.p_shld_secondary_heat_mw,
        )
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heating in TF coils [MW]",
            "(p_tf_nuclear_heat_mw)",
            fwbs_variables.p_tf_nuclear_heat_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Neutronic nuclear heating in H&CD systems and diagnostics [MW]",
            "(p_fw_hcd_nuclear_heat_mw)",
            fwbs_variables.p_fw_hcd_nuclear_heat_mw,
        )
        po.ovarre(
            self.outfile,
            "Radiation heat deposited in H&CD systems and diagnostics [MW]",
            "(p_fw_hcd_rad_total_mw)",
            fwbs_variables.p_fw_hcd_rad_total_mw,
        )
        po.ovarre(
            self.outfile,
            "Total heat deposited in in H&CD systems and diagnostics [MW]",
            "(p_hcd_secondary_heat_mw)",
            heat_transport_variables.p_hcd_secondary_heat_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total secondary heat not used for electricity production [MW]",
            "(p_plant_secondary_heat_mw)",
            heat_transport_variables.p_plant_secondary_heat_mw,
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Primary heat : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total heat deposited in FW and coolant [MW]",
            "(p_fw_heat_deposited_mw)",
            power_variables.p_fw_heat_deposited_mw,
        )
        po.ovarre(
            self.outfile,
            "Total heat deposited in Blanket(s) and coolant [MW]",
            "(p_blkt_heat_deposited_mw)",
            power_variables.p_blkt_heat_deposited_mw,
        )
        po.ovarre(
            self.outfile,
            "Total heat deposited in Blanket(s) and FW coolant [MW]",
            "(p_fw_blkt_heat_deposited_mw)",
            power_variables.p_fw_blkt_heat_deposited_mw,
        )
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total heat deposited in VV and shield coolant(s) [MW]",
            "(p_shld_heat_deposited_mw)",
            power_variables.p_shld_heat_deposited_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total heat deposited in divertor and coolants [MW]",
            "(p_div_heat_deposited_mw)",
            power_variables.p_div_heat_deposited_mw,
        )
        po.ovarre(
            self.outfile,
            "Fraction of total primary heat originating from divertor",
            "(f_p_div_primary_heat)",
            power_variables.f_p_div_primary_heat,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total primary thermal power used for electricity production [MW]",
            "(p_plant_primary_heat_mw)",
            heat_transport_variables.p_plant_primary_heat_mw,
        )

    def output_plant_electric_powers(self):
        po.oheadr(self.outfile, "Plant Electricity Production")

        po.ocmmnt(self.outfile, "Turbine conversion : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total high grade thermal power used for electricity production [MWth]",
            "(p_plant_primary_heat_mw)",
            heat_transport_variables.p_plant_primary_heat_mw,
        )

        po.ovarrf(
            self.outfile,
            "Thermal to electric conversion efficiency of the turbine",
            "(eta_turbine)",
            heat_transport_variables.eta_turbine,
        )
        po.ovarre(
            self.outfile,
            "Total thermal power lost in power conversion [MWth]",
            "(p_turbine_loss_mw)",
            power_variables.p_turbine_loss_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total electric power produced [MWe]",
            "(p_plant_electric_gross_mw)",
            heat_transport_variables.p_plant_electric_gross_mw,
        )
        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "----------------------------")
        po.oblnkl(self.outfile)

        po.ocmmnt(self.outfile, "Electric requirements of core plant systems : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Base plant electric load [We]",
            "(p_plant_electric_base)",
            heat_transport_variables.p_plant_electric_base,
        )
        po.ovarre(
            self.outfile,
            "Electric power per unit area of plant floor space [We/m^2]",
            "(pflux_plant_floor_electric)",
            heat_transport_variables.pflux_plant_floor_electric,
        )
        po.ovarre(
            self.outfile,
            "Effective area of plant buildings floor [m^2]",
            "(a_plant_floor_effective)",
            buildings_variables.a_plant_floor_effective,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total base plant electric load [MWe]",
            "(p_plant_electric_base_total_mw)",
            heat_transport_variables.p_plant_electric_base_total_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Electric power demand for cryo plant [MWe]",
            "(p_cryo_plant_electric_mw)",
            heat_transport_variables.p_cryo_plant_electric_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand for tritium plant [MWe]",
            "(p_tritium_plant_electric_mw)",
            heat_transport_variables.p_tritium_plant_electric_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand for vacuum pumps [MWe]",
            "(vachtmw)",
            heat_transport_variables.vachtmw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand for TF coil system [MWe]",
            "(p_tf_electric_supplies_mw)",
            heat_transport_variables.p_tf_electric_supplies_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand for PF coil system [MWe]",
            "(p_pf_electric_supplies_mw)",
            pfcoil_variables.p_pf_electric_supplies_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand for CP coolant pumps [MWe]",
            "(p_cp_coolant_pump_elec_mw)",
            power_variables.p_cp_coolant_pump_elec_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Electric power demand of core plant systems needed at all times [MWe]",
            "(p_plant_core_systems_elec_mw)",
            power_variables.p_plant_core_systems_elec_mw,
        )

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

        po.ocmmnt(self.outfile, "Electric requirements during plasma flat-top : ")
        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Electric power demand of FW and Blanket coolant pumps [MWe]",
            "(p_fw_blkt_coolant_pump_elec_mw)",
            power_variables.p_fw_blkt_coolant_pump_elec_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand of Blanket secondary breeder coolant pumps [MWe]",
            "(p_blkt_breeder_pump_elec_mw)",
            power_variables.p_blkt_breeder_pump_elec_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand of VV and Shield coolant pumps [MWe]",
            "(p_shld_coolant_pump_elec_mw)",
            power_variables.p_shld_coolant_pump_elec_mw,
        )
        po.ovarre(
            self.outfile,
            "Electric power demand of Divertor colant pumps [MWe]",
            "(p_div_coolant_pump_elec_mw)",
            power_variables.p_div_coolant_pump_elec_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Electric wall plug efficiency of coolant pumps",
            "(eta_coolant_pump_electric)",
            fwbs_variables.eta_coolant_pump_electric,
        )
        po.ovarre(
            self.outfile,
            "Total electric demand of all coolant pumps [MWe]",
            "(p_coolant_pump_elec_total_mw)",
            heat_transport_variables.p_coolant_pump_elec_total_mw,
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Total electric demand of all H&CD systems [MWe]",
            "(p_hcd_electric_total_mw)",
            heat_transport_variables.p_hcd_electric_total_mw,
        )

        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total re-circulated electric power of the plant [MWe]",
            "(p_plant_electric_recirc_mw)",
            heat_transport_variables.p_plant_electric_recirc_mw,
        )
        po.ovarre(
            self.outfile,
            "Fraction of gross electricity re-circulated",
            "(f_p_plant_electric_recirc)",
            heat_transport_variables.f_p_plant_electric_recirc,
        )

        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total net-electric power of the plant [MWe]",
            "(p_plant_electric_net_mw)",
            heat_transport_variables.p_plant_electric_net_mw,
        )

        po.oblnkl(self.outfile)

        po.ovarre(
            self.outfile,
            "Total electric energy output per pulse (MJ)",
            "(e_plant_net_electric_pulse_mj)",
            power_variables.e_plant_net_electric_pulse_mj,
        )
        po.ovarre(
            self.outfile,
            "Total electric energy output per pulse (kWh)",
            "(e_plant_net_electric_pulse_kwh)",
            power_variables.e_plant_net_electric_pulse_kwh,
        )

    def plant_electric_production(self):
        """This method completes the calculation of the plant's electrical and thermal power flows,
        including secondary heat, recirculating power, net and gross electric power, and various
        efficiency measures.

        If `output` is True, the method writes a comprehensive summary of the plant's power and
        heat transport balance, assumptions, and efficiency metrics to the specified output file.
        """
        if physics_variables.itart == 1 and tfcoil_variables.i_tf_sup == 0:
            power_variables.p_cp_coolant_pump_elec_mw = (
                1.0e-6 * tfcoil_variables.p_cp_coolant_pump_elec
            )
        else:
            power_variables.p_cp_coolant_pump_elec_mw = 0.0e0

        #  Total baseline power to facility loads, MW
        heat_transport_variables.p_plant_electric_base_total_mw = (
            heat_transport_variables.p_plant_electric_base * 1.0e-6
            + buildings_variables.a_plant_floor_effective
            * (heat_transport_variables.pflux_plant_floor_electric * 1.0e-3)
            / 1000.0e0
        )

        #  Facility heat removal (heat_transport_variables.p_plant_electric_base_total_mw calculated in ACPOW)
        heat_transport_variables.fachtmw = (
            heat_transport_variables.p_plant_electric_base_total_mw
        )

        #  Electrical power consumed by fusion power core systems
        #  (excluding heat transport pumps and auxiliary injection power system)

        power_variables.p_plant_core_systems_elec_mw = (
            heat_transport_variables.p_cryo_plant_electric_mw
            + heat_transport_variables.fachtmw
            + power_variables.p_cp_coolant_pump_elec_mw
            + heat_transport_variables.p_tf_electric_supplies_mw
            + heat_transport_variables.p_tritium_plant_electric_mw
            + heat_transport_variables.vachtmw
            + pfcoil_variables.p_pf_electric_supplies_mw
        )

        #  Total secondary heat
        #  (total low-grade heat rejected - does not contribute to power conversion cycle)
        #  Included fwbs_variables.p_tf_nuclear_heat_mw
        # p_plant_secondary_heat_mw = power_variables.p_plant_core_systems_elec_mw + heat_transport_variables.p_hcd_electric_loss_mw + heat_transport_variables.p_coolant_pump_loss_total_mw + hthermmw + heat_transport_variables.p_div_secondary_heat_mw + heat_transport_variables.p_shld_secondary_heat_mw + heat_transport_variables.p_hcd_secondary_heat_mw + fwbs_variables.p_tf_nuclear_heat_mw
        heat_transport_variables.p_plant_secondary_heat_mw = (
            power_variables.p_plant_core_systems_elec_mw
            + heat_transport_variables.p_hcd_electric_loss_mw
            + heat_transport_variables.p_coolant_pump_loss_total_mw
            + heat_transport_variables.p_div_secondary_heat_mw
            + heat_transport_variables.p_shld_secondary_heat_mw
            + heat_transport_variables.p_hcd_secondary_heat_mw
            + fwbs_variables.p_tf_nuclear_heat_mw
        )

        #  Calculate powers relevant to a power-producing plant
        if cost_variables.ireactor == 1:
            #  Gross electric power
            # p_plant_electric_gross_mw = (heat_transport_variables.p_plant_primary_heat_mw-hthermmw) * heat_transport_variables.eta_turbine
            if (
                fwbs_variables.i_blkt_dual_coolant > 0
                and fwbs_variables.i_p_coolant_pumping == 2
            ):
                heat_transport_variables.p_plant_electric_gross_mw = (
                    (
                        heat_transport_variables.p_plant_primary_heat_mw
                        - power_variables.p_blkt_liquid_breeder_heat_deposited_mw
                    )
                    * heat_transport_variables.eta_turbine
                    + power_variables.p_blkt_liquid_breeder_heat_deposited_mw
                    * heat_transport_variables.etath_liq
                )
            else:
                heat_transport_variables.p_plant_electric_gross_mw = (
                    heat_transport_variables.p_plant_primary_heat_mw
                    * heat_transport_variables.eta_turbine
                )

            # Total lost thermal power in the turbine
            power_variables.p_turbine_loss_mw = (
                heat_transport_variables.p_plant_primary_heat_mw
                * (1 - heat_transport_variables.eta_turbine)
            )

            #  Total recirculating power
            heat_transport_variables.p_plant_electric_recirc_mw = (
                power_variables.p_plant_core_systems_elec_mw
                + heat_transport_variables.p_hcd_electric_total_mw
                + heat_transport_variables.p_coolant_pump_elec_total_mw
            )

            #  Net electric power
            heat_transport_variables.p_plant_electric_net_mw = (
                heat_transport_variables.p_plant_electric_gross_mw
                - heat_transport_variables.p_plant_electric_recirc_mw
            )

            #  Recirculating power fraction
            heat_transport_variables.f_p_plant_electric_recirc = (
                heat_transport_variables.p_plant_electric_gross_mw
                - heat_transport_variables.p_plant_electric_net_mw
            ) / heat_transport_variables.p_plant_electric_gross_mw

        (
            power_variables.e_plant_net_electric_pulse_kwh,
            power_variables.e_plant_net_electric_pulse_mj,
            power_variables.p_plant_electric_base_total_profile_mw,
            power_variables.p_plant_electric_gross_profile_mw,
            power_variables.p_plant_electric_net_profile_mw,
            power_variables.p_hcd_electric_total_profile_mw,
            power_variables.p_coolant_pump_elec_total_profile_mw,
            power_variables.p_tf_electric_supplies_profile_mw,
            power_variables.p_pf_electric_supplies_profile_mw,
            power_variables.vachtmw_profile_mw,
            power_variables.p_tritium_plant_electric_profile_mw,
            power_variables.p_cryo_plant_electric_profile_mw,
            power_variables.p_fusion_total_profile_mw,
        ) = self.power_profiles_over_time(
            t_precharge=times_variables.t_plant_pulse_coil_precharge,
            t_current_ramp_up=times_variables.t_plant_pulse_plasma_current_ramp_up,
            t_fusion_ramp=times_variables.t_plant_pulse_fusion_ramp,
            t_burn=times_variables.t_plant_pulse_burn,
            t_ramp_down=times_variables.t_plant_pulse_plasma_current_ramp_down,
            t_between_pulse=times_variables.t_plant_pulse_dwell,
            p_plant_electric_base_total_mw=heat_transport_variables.p_plant_electric_base_total_mw,
            p_cryo_plant_electric_mw=heat_transport_variables.p_cryo_plant_electric_mw,
            p_tritium_plant_electric_mw=heat_transport_variables.p_tritium_plant_electric_mw,
            vachtmw=heat_transport_variables.vachtmw,
            p_tf_electric_supplies_mw=heat_transport_variables.p_tf_electric_supplies_mw,
            p_pf_electric_supplies_mw=pfcoil_variables.p_pf_electric_supplies_mw,
            p_coolant_pump_elec_total_mw=heat_transport_variables.p_coolant_pump_elec_total_mw,
            p_hcd_electric_total_mw=heat_transport_variables.p_hcd_electric_total_mw,
            p_fusion_total_mw=physics_variables.p_fusion_total_mw,
            p_plant_electric_gross_mw=heat_transport_variables.p_plant_electric_gross_mw,
            p_plant_electric_net_mw=heat_transport_variables.p_plant_electric_net_mw,
        )

    def cryo(
        self,
        i_tf_sup,
        tfcryoarea,
        coldmass,
        p_tf_nuclear_heat_mw,
        ensxpfm,
        t_plant_pulse_plasma_present,
        c_tf_turn,
        n_tf_coils,
    ):
        """Calculates cryogenic loads

        itfsup : input integer : Switch denoting whether TF coils are
        superconducting
        tfcryoarea : input real : Surface area of toroidal shells covering TF coils (m2)
        coldmass : input real : Mass of cold (cryogenic) components (kg),
        including TF coils, PF coils, cryostat, and
        intercoil structure
        p_tf_nuclear_heat_mw : input real : Nuclear heating in TF coils (MW)
        ensxpfm : input real : Maximum PF coil stored energy (MJ)
        t_plant_pulse_plasma_present : input real : Pulse length of cycle (s)
        c_tf_turn : input real : Current per turn in TF coils (A)
        tfno : input real : Number of TF coils
        helpow : output real : Helium heat removal at cryo temperatures (W)
        This routine calculates the cryogenic heat load.
        D. Slack memo SCMDG 88-5-1-059, LLNL ITER-88-054, Aug. 1988

        Parameters
        ----------
        i_tf_sup :

        tfcryoarea :

        coldmass :

        p_tf_nuclear_heat_mw :

        ensxpfm :

        t_plant_pulse_plasma_present :

        c_tf_turn :

        n_tf_coils :

        """
        power_variables.qss = 4.3e-4 * coldmass
        if i_tf_sup == 1:
            power_variables.qss = power_variables.qss + 2.0e0 * tfcryoarea

        #  Nuclear heating of TF coils (W) (zero if resistive)
        if fwbs_variables.inuclear == 0 and i_tf_sup == 1:
            fwbs_variables.qnuc = 1.0e6 * p_tf_nuclear_heat_mw
        # Issue #511: if fwbs_variables.inuclear = 1 : fwbs_variables.qnuc is input.

        #  AC losses
        power_variables.qac = 1.0e3 * ensxpfm / t_plant_pulse_plasma_present

        #  Current leads
        if i_tf_sup == 1:
            power_variables.qcl = 13.6e-3 * n_tf_coils * c_tf_turn
        else:
            power_variables.qcl = 0.0e0

        #  45% extra miscellaneous, piping and reserves
        power_variables.qmisc = 0.45e0 * (
            power_variables.qss
            + fwbs_variables.qnuc
            + power_variables.qac
            + power_variables.qcl
        )
        return max(
            0.0e0,
            power_variables.qmisc
            + power_variables.qss
            + fwbs_variables.qnuc
            + power_variables.qac
            + power_variables.qcl,
        )

    def output_cryogenics(self):
        """Outputs cryogenic system heat loads and related parameters to the output file.

        This method prints the breakdown of cryogenic heat loads, including conduction/radiation,
        nuclear heating, AC losses, resistive losses in current leads, miscellaneous allowances,
        and total heat removal at cryogenic temperatures. It also outputs the temperatures and
        efficiencies of the cryogenic systems, as well as the electric power required for the
        cryogenic plant.
        """

        po.oheadr(self.outfile, "Cryogenics")
        po.ovarre(
            self.outfile,
            "Conduction and radiation heat loads on cryogenic components (MW)",
            "(qss/1.0d6)",
            power_variables.qss / 1.0e6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Nuclear heating of cryogenic components (MW)",
            "(qnuc/1.0d6)",
            fwbs_variables.qnuc / 1.0e6,
            "OP ",
        )
        if fwbs_variables.inuclear == 1:
            po.ocmmnt(
                self.outfile, "Nuclear heating of cryogenic components is a user input."
            )
        po.ovarre(
            self.outfile,
            "AC losses in cryogenic components (MW)",
            "(qac/1.0d6)",
            power_variables.qac / 1.0e6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Resistive losses in current leads (MW)",
            "(qcl/1.0d6)",
            power_variables.qcl / 1.0e6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "45% allowance for heat loads in transfer lines, storage tanks etc (MW)",
            "(qmisc/1.0d6)",
            power_variables.qmisc / 1.0e6,
            "OP ",
        )

        po.ovarre(
            self.outfile,
            "Sum = Total heat removal at cryogenic temperatures (temp_tf_cryo & temp_cp_coolant_inlet) (MW)",
            "(helpow + helpow_cryal/1.0d6)",
            (heat_transport_variables.helpow + heat_transport_variables.helpow_cryal)
            * 1.0e-6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Temperature of cryogenic superconducting components (K)",
            "(temp_tf_cryo)",
            tfcoil_variables.temp_tf_cryo,
        )
        po.ovarre(
            self.outfile,
            "Temperature of cryogenic aluminium components (K)",
            "(temp_cp_coolant_inlet)",
            tfcoil_variables.temp_cp_coolant_inlet,
        )
        po.ovarre(
            self.outfile,
            "Electric power for cryogenic plant (MW)",
            "(p_cryo_plant_electric_mw)",
            heat_transport_variables.p_cryo_plant_electric_mw,
            "OP ",
        )

    def plant_thermal_efficiency(self, eta_turbine):
        """Calculates the thermal efficiency of the power conversion cycle


        eta_turbine : input/output real : thermal to electric conversion efficiency
        This routine calculates the thermal efficiency of the power conversion cycle.
        This gives the gross power of the plant, i.e. the primary coolant pumping
        power is not subtracted at this point; however, the pumping of the
        secondary coolant is accounted for.
        <P>If i_thermal_electric_conversion = 0, 1, a set efficiency for the chosen blanket design is used,
        taken from cycle modelling studies.
        <P>If i_thermal_electric_conversion > 1, the outlet temperature from the first wall
        and breeder zone is used to calculate an efficiency, using a simple relationship
        between eta_turbine and temp_blkt_coolant_out again obtained from previous studies.
        C. Harrington, K:Power Plant Physics and Technology  PROCESS  blanket_model
         New Power Module Harrington  Cycle correlations  Cycle correlations.xls

        Parameters
        ----------
        eta_turbine :

        """
        if fwbs_variables.i_thermal_electric_conversion == 0:
            #  CCFE HCPB Model
            if fwbs_variables.i_blanket_type == 1:
                #  HCPB, efficiency taken from M. Kovari 2016
                # "PROCESS": A systems code for fusion power plants - Part 2: Engineering
                # https://www.sciencedirect.com/science/article/pii/S0920379616300072
                # Feedheat & reheat cycle assumed
                eta_turbine = 0.411e0
            else:
                logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

            #  Etath from reference. Div power to primary
        elif fwbs_variables.i_thermal_electric_conversion == 1:
            #  CCFE HCPB Model
            if fwbs_variables.i_blanket_type == 1:
                #  HCPB, efficiency taken from M. Kovari 2016
                # "PROCESS": A systems code for fusion power plants - Part 2: Engineering
                # https://www.sciencedirect.com/science/article/pii/S0920379616300072
                # Feedheat & reheat cycle assumed
                eta_turbine = 0.411e0 - power_variables.delta_eta
            else:
                logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

            #  User input used, eta_turbine not changed
        elif fwbs_variables.i_thermal_electric_conversion == 2:
            return eta_turbine
            # Do nothing

            #  Steam Rankine cycle to be used
        elif fwbs_variables.i_thermal_electric_conversion == 3:
            #  CCFE HCPB Model
            if fwbs_variables.i_blanket_type == 1:
                #  If coolant is helium, the steam cycle is assumed to be superheated
                #  and a different correlation is used. The turbine inlet temperature
                #  is assumed to be 20 degrees below the primary coolant outlet
                #  temperature, as was stated for steam rankine cycle for Helium in
                #  M. Kovari 2016, "PROCESS": A systems code for fusion power plants
                #  - Part 2: Engineering
                #  https://www.sciencedirect.com/science/article/pii/S0920379616300072

                #  Superheated steam Rankine cycle correlation (C. Harrington)
                #  Range of validity: 657 K < heat_transport_variables.temp_turbine_coolant_in < 915 K
                heat_transport_variables.temp_turbine_coolant_in = (
                    fwbs_variables.temp_blkt_coolant_out - 20.0e0
                )
                if (heat_transport_variables.temp_turbine_coolant_in < 657.0e0) or (
                    heat_transport_variables.temp_turbine_coolant_in > 915.0e0
                ):
                    logger.warning(
                        "Turbine temperature temp_turbine_coolant_in out of range of validity"
                        f"{heat_transport_variables.temp_turbine_coolant_in=}"
                    )

                eta_turbine = (
                    0.1802e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
                    - 0.7823
                    - power_variables.delta_eta
                )

            else:
                logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

            #  Supercritical CO2 cycle to be used
        elif fwbs_variables.i_thermal_electric_conversion == 4:
            #  The same temperature/efficiency correlation is used regardless of
            #  primary coolant choice.  The turbine inlet temperature is assumed to
            #  be 20 degrees below the primary coolant outlet temperature.
            #  s-CO2 can in theory be used for both helium and water primary coolants
            #  so no differentiation is made, but for water the efficiency will be
            #  very low and the correlation will reflect this.

            #  Supercritical CO2 cycle correlation (C. Harrington)
            #  Range of validity: 408 K < heat_transport_variables.temp_turbine_coolant_in < 1023 K
            heat_transport_variables.temp_turbine_coolant_in = (
                fwbs_variables.temp_blkt_coolant_out - 20.0e0
            )
            if (heat_transport_variables.temp_turbine_coolant_in < 408.0e0) or (
                heat_transport_variables.temp_turbine_coolant_in > 1023.0e0
            ):
                logger.warning(
                    "Turbine temperature temp_turbine_coolant_in out of range of validity"
                    f"{heat_transport_variables.temp_turbine_coolant_in=}"
                )

            eta_turbine = (
                0.4347e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
                - 2.5043e0
            )

        else:
            logger.log(
                f"{'i_thermal_electric_conversion does not appear to have a value within its range (0-4)'}"
            )
        return eta_turbine

    def plant_thermal_efficiency_2(self, etath_liq):
        """Calculates the thermal efficiency of the power conversion cycle
        for the liquid metal breeder

        Parameters
        ----------
        etath_liq :

        """
        if fwbs_variables.secondary_cycle_liq == 2:
            #  User input used, eta_turbine not changed
            return etath_liq

        if fwbs_variables.secondary_cycle_liq == 4:
            #  Supercritical CO2 cycle to be used
            #  Supercritical CO2 cycle correlation (C. Harrington)
            #  Range of validity: 408 K < heat_transport_variables.temp_turbine_coolant_in < 1023 K
            heat_transport_variables.temp_turbine_coolant_in = (
                fwbs_variables.outlet_temp_liq - 20.0e0
            )
            if (heat_transport_variables.temp_turbine_coolant_in < 408.0e0) or (
                heat_transport_variables.temp_turbine_coolant_in > 1023.0e0
            ):
                logger.warning(
                    "Turbine temperature temp_turbine_coolant_in out of range of validity"
                    f"{heat_transport_variables.temp_turbine_coolant_in=}"
                )

            return (
                0.4347e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
                - 2.5043e0
            )

        raise ProcessValueError(
            f"secondary_cycle_liq ={fwbs_variables.secondary_cycle_liq} is an invalid option."
        )

    def tfpwr(self, output: bool):
        """TF coil power supply requirements for resistive coils

        outfile : input integer : output file unit
        iprint : input integer : switch for writing to output (1=yes)
        This routine calculates the power conversion requirements for
        resistive TF coils, or calls <CODE>tfpwcall</CODE> if the TF
        coils are superconducting.
        None

        Parameters
        ----------
        output: bool

        """
        if tfcoil_variables.i_tf_sup != 1:
            # Cross-sectional area of bus
            # tfcoil_variables.c_tf_turn  - current per TFC turn (A)
            # tfcoil_variables.j_tf_bus   - bus current density (A/m2)
            a_tf_bus = tfcoil_variables.c_tf_turn / tfcoil_variables.j_tf_bus

            # Bus resistance [ohm]
            # Bus resistivity (tfcoil_variables.rho_tf_bus)
            # Issue #1253: there was a fudge here to set the bus bar resistivity equal
            # to the TF conductor resistivity. I have removed this.
            tfbusres = (
                tfcoil_variables.rho_tf_bus * tfcoil_variables.len_tf_bus / a_tf_bus
            )

            #  Bus mass (kg)
            tfcoil_variables.m_tf_bus = (
                tfcoil_variables.len_tf_bus * a_tf_bus * constants.den_copper
            )

            #  Total maximum impedance MDK actually just fixed resistance
            res_tf_system_total = (
                tfcoil_variables.n_tf_coils * tfcoil_variables.res_tf_leg
                + (tfcoil_variables.p_cp_resistive / tfcoil_variables.c_tf_total**2)
                + tfbusres
            )

            #  No reactive portion of the voltage is included here - assume long ramp times
            #  MDK This is steady state voltage, not "peak" voltage
            tfcoil_variables.vtfkv = (
                1.0e-3
                * res_tf_system_total
                * tfcoil_variables.c_tf_turn
                / tfcoil_variables.n_tf_coils
            )

            # Resistive powers (MW):
            tfcoil_variables.p_cp_resistive_mw = (
                1.0e-6 * tfcoil_variables.p_cp_resistive
            )  # inboard legs (called centrepost, CP for tart design)
            tfcoil_variables.p_tf_leg_resistive_mw = (
                1.0e-6 * tfcoil_variables.p_tf_leg_resistive
            )  # outboard legs
            tfcoil_variables.p_tf_joints_resistive_mw = (
                1.0e-6 * tfcoil_variables.p_tf_joints_resistive
            )  # Joints
            tfbusmw = (
                1.0e-6 * tfcoil_variables.c_tf_turn**2 * tfbusres
            )  # TF coil bus => Dodgy #

            #  TF coil reactive power
            #  Set reactive power to 0, since ramp up can be long
            #  The TF coil can be ramped up as slowly as you like
            #  (although this will affect the time to recover from a magnet quench).
            #     tfreacmw = 1.0e-6 * 1.0e9 * estotf/(t_plant_pulse_plasma_current_ramp_up + t_plant_pulse_coil_precharge)
            #                                 estotf(=e_tf_magnetic_stored_total_gj/tfcoil_variables.n_tf_coils) has been removed (#199 #847)
            tfreacmw = 0.0e0

            # Total power consumption (MW)
            tfcoil_variables.tfcmw = (
                tfcoil_variables.p_cp_resistive_mw
                + tfcoil_variables.p_tf_leg_resistive_mw
                + tfbusmw
                + tfreacmw
                + tfcoil_variables.p_tf_joints_resistive_mw
            )

            # Total steady state AC power demand (MW)
            heat_transport_variables.p_tf_electric_supplies_mw = (
                tfcoil_variables.tfcmw / heat_transport_variables.etatf
            )

        else:  # Superconducting TF coil option
            self.tfpwcall(output)
            return

        # Output section
        if output == 0:
            return
        # Clarify that these outputs are for resistive coils only
        po.oheadr(self.outfile, "Resistive TF Coil Power Conversion")
        po.ovarre(self.outfile, "Bus resistance (ohm)", "(tfbusres)", tfbusres, "OP ")
        po.ovarre(
            self.outfile,
            "Bus current density (A/m2)",
            "(j_tf_bus)",
            tfcoil_variables.j_tf_bus,
        )
        po.ovarre(
            self.outfile,
            "Bus length - all coils (m)",
            "(len_tf_bus)",
            tfcoil_variables.len_tf_bus,
        )
        po.ovarre(
            self.outfile,
            "Bus mass (kg)",
            "(m_tf_bus)",
            tfcoil_variables.m_tf_bus,
            "OP ",
        )
        # po.ovarre(outfile,'Maximum impedance (ohm)','(ztot)',ztot)
        po.ovarre(
            self.outfile,
            "Total resistance for TF coil set (ohm)",
            "(res_tf_system_total)",
            res_tf_system_total,
            "OP ",
        )
        # po.ovarre(outfile,'Peak voltage per coil (kV)','(vtfkv)',vtfkv)
        po.ovarre(
            self.outfile,
            "Steady-state voltage per coil (kV)",
            "(vtfkv)",
            tfcoil_variables.vtfkv,
            "OP ",
        )
        # po.ovarre(outfile,'Peak power (MW)','(tfcmw..)',tfcmw)
        po.ovarre(
            self.outfile,
            "Total power dissipation in TF coil set (MW)",
            "(tfcmw..)",
            tfcoil_variables.tfcmw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Power dissipation in TF coil set: inboard legs (MW)",
            "(p_cp_resistive_mw)",
            tfcoil_variables.p_cp_resistive_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Power dissipation in TF coil set: outboard legs (MW)",
            "(p_tf_leg_resistive_mw)",
            tfcoil_variables.p_tf_leg_resistive_mw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Power dissipation in TF coil set: buses",
            "(tfbusmw)",
            tfbusmw,
            "OP ",
        )
        if tfcoil_variables.i_cp_joints != 0:
            po.ovarre(
                self.outfile,
                "Power dissipation in TF coil set: joints",
                "(p_tf_joints_resistive_mw)",
                tfcoil_variables.p_tf_joints_resistive_mw,
                "OP ",
            )

        # Reactive poower has been set to zero.
        # po.ovarre(outfile,'TF coil reactive power (MW)','(tfreacmw)', tfreacmw)

    def tfpwcall(self, output: bool):
        """Calls the TF coil power conversion routine for
        superconducting coils


        outfile : input integer : output file unit
        iprint : input integer : switch for writing to output (1=yes)
        This routine calls routine <CODE>tfcpwr</CODE> to calculate
        the power conversion requirements for superconducting TF coils.
        None

        Parameters
        ----------
        output: bool

        """
        ettfmj = (
            tfcoil_variables.e_tf_magnetic_stored_total_gj
            / tfcoil_variables.n_tf_coils
            * 1.0e3
        )

        #  TF coil current (kA)

        itfka = 1.0e-3 * tfcoil_variables.c_tf_turn

        (
            tfcoil_variables.tfckw,
            tfcoil_variables.len_tf_bus,
            tfcoil_variables.drarea,
            buildings_variables.tfcbv,
            heat_transport_variables.p_tf_electric_supplies_mw,
        ) = self.tfcpwr(
            output,
            itfka,
            physics_variables.rmajor,
            tfcoil_variables.n_tf_coils,
            tfcoil_variables.v_tf_coil_dump_quench_kv,
            ettfmj,
            tfcoil_variables.res_tf_leg,
        )

    def tfcpwr(
        self, output: bool, itfka, rmajor, ntfc, v_tf_coil_dump_quench_kv, ettfmj, rptfc
    ):
        """Calculates the TF coil power conversion system parameters
        for superconducting coils

        This routine calculates the TF power conversion systemp arameters:
        floor space, power supplies, bussing,
        coil protection equipment, and the associated controls
        and instrumentation.

        Parameters
        ----------
        itfka :

        rmajor :

        ntfc :

        v_tf_coil_dump_quench_kv :

        ettfmj :

        rptfc :

        """

        ncpbkr = 1.0e0  # number of TF coils per circuit breaker
        djmka = 0.125e0  # design current density of TF bus, kA/cm2
        rtfps = 1.05e0  # rating factor for TF coil power supplies
        fspc1 = 0.15e0  # floor space coefficient for power supplies
        fspc2 = 0.8e0  # floor space coefficient for circuit breakers
        fspc3 = 0.4e0  # floor space coefficient for load centres

        if rptfc == 0.0e0:
            tchghr = 4.0e0  # charge time of the coils, hours
            nsptfc = 1.0e0  # superconducting (1.0 = superconducting, 0.0 = resistive)
        else:
            tchghr = 0.16667e0  # charge time of the coils, hours
            nsptfc = 0.0e0  # resistive (1.0 = superconducting, 0.0 = resistive)

        #  Total steady state TF coil AC power demand (summed later)
        p_tf_electric_supplies_mw = 0.0e0

        #  Stored energy of all TF coils, MJ
        ettfc = ntfc * ettfmj

        #  Inductance of all TF coils, Henries
        ltfth = 2.0e0 * ettfc / itfka**2

        #  Number of circuit breakers
        ntfbkr = ntfc / ncpbkr

        #  Inductance per TF coil, Henries
        lptfcs = ltfth / ntfc

        #  Aluminium bus section area, sq cm
        albusa = itfka / djmka

        #  Total TF system bus length, m
        len_tf_bus = (
            8.0e0 * np.pi * rmajor
            + (1.0e0 + ntfbkr) * (12.0e0 * rmajor + 80.0e0)
            + 0.2e0 * itfka * np.sqrt(ntfc * rptfc * 1000.0e0)
        )

        #  Aluminium bus weight, tonnes
        albuswt = 2.7e0 * albusa * len_tf_bus / 1.0e4

        #  Total resistance of TF bus, ohms
        # rtfbus = 2.62e-4 * len_tf_bus / albusa
        rtfbus = tfcoil_variables.rho_tf_bus * len_tf_bus / (albusa / 10000)

        #  Total voltage drop across TF bus, volts
        vtfbus = 1000.0e0 * itfka * rtfbus

        #  Total resistance of the TF coils, ohms
        rcoils = ntfc * rptfc

        #  Total impedance, ohms
        ztotal = rtfbus + rcoils + ltfth / (3600.0e0 * tchghr)

        #  Charging voltage for the TF coils, volts
        tfcv = 1000.0e0 * itfka * ztotal

        #  Number of TF power modules
        ntfpm = (itfka * (1.0e0 + nsptfc)) / 5.0e0

        #  TF coil power module voltage, volts
        tfpmv = rtfps * tfcv / (1.0e0 + nsptfc)

        #  TF coil power supply voltage, volts
        tfpsv = rtfps * tfcv

        #  Power supply current, kA
        tfpska = rtfps * itfka

        #  TF power module current, kA
        tfpmka = rtfps * itfka / (ntfpm / (1.0e0 + nsptfc))

        #  TF power module power, kW
        tfpmkw = tfpmv * tfpmka

        #  Available DC power for charging the TF coils, kW
        tfckw = tfpmkw * ntfpm

        #  Peak AC power needed to charge coils, kW
        tfackw = tfckw / 0.9e0

        #  Resistance of dump resistor, ohms
        r1dump = nsptfc * v_tf_coil_dump_quench_kv * ncpbkr / itfka

        #  Time constant, s
        ttfsec = lptfcs * ncpbkr / (r1dump * nsptfc + rptfc * (1.0e0 - nsptfc))

        #  Number of dump resistors
        ndumpr = ntfbkr * 4.0e0

        #  Peak power to a dump resistor during quench, MW
        r1ppmw = nsptfc * r1dump * (itfka / 2.0e0) ** 2

        #  Energy to dump resistor during quench, MJ
        r1emj = nsptfc * ettfc / (ndumpr + 0.0001e0)

        #  Total TF coil peak resistive power demand, MVA
        rpower = (ntfc * rptfc + rtfbus) * itfka**2

        #  Total TF coil peak inductive power demand, MVA
        xpower = ltfth / (3600.0e0 * tchghr) * itfka**2

        #  Building space:
        #  Power modules floor space, m2
        part1 = fspc1 * ntfpm * tfpmkw**0.667e0

        #  Circuit breakers floor space, m2
        part2 = fspc2 * ntfbkr * (v_tf_coil_dump_quench_kv * itfka) ** 0.667e0

        #  Load centres floor space, m2
        part3 = (
            fspc3 * (tfackw / (2.4e0 * nsptfc + 13.8e0 * (1.0e0 - nsptfc))) ** 0.667e0
        )

        #  Power conversion building floor area, m2
        tfcfsp = part1 + part2 + part3

        #  Dump resistor floor area, m2
        drarea = 0.5e0 * ndumpr * (1.0e0 + r1emj) ** 0.667e0

        #  Total TF coil power conversion building volume, m3
        tfcbv = 6.0e0 * tfcfsp

        #  TF coil AC inductive power demand, MW
        xpwrmw = xpower / 0.9e0

        #  Total steady state AC power demand, MW
        p_tf_electric_supplies_mw = (
            p_tf_electric_supplies_mw + rpower / heat_transport_variables.etatf
        )
        #  Total TF coil power conversion building floor area, m2

        # tftsp = tfcfsp
        #  Total TF coil power conversion building volume, m3

        # tftbv = tfcbv

        #  Output section
        if output:
            po.oheadr(self.outfile, "Superconducting TF Coil Power Conversion")
            po.ovarre(self.outfile, "TF coil current (kA)", "(itfka)", itfka, "OP ")
            po.ovarre(self.outfile, "Number of TF coils", "(ntfc)", ntfc)
            po.ovarre(
                self.outfile,
                "Voltage across a TF coil during quench (kV)",
                "(v_tf_coil_dump_quench_kv)",
                v_tf_coil_dump_quench_kv,
                "OP ",
            )
            po.ovarre(self.outfile, "TF coil charge time (hours)", "(tchghr)", tchghr)
            po.ovarre(
                self.outfile,
                "Total inductance of TF coils (H)",
                "(ltfth)",
                ltfth,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total resistance of TF coils (ohm)",
                "(rcoils)",
                rcoils,
                "OP ",
            )
            # MDK Remove this as it leads to confusion between (a) total inductance/n_tf_coils, or (b)
            #     self-inductance of one single coil
            # po.ovarre(outfile,'Inductance per TF coil (H)','(lptfcs)',lptfcs, 'OP ')
            po.ovarre(self.outfile, "TF coil charging voltage (V)", "(tfcv)", tfcv)
            po.ovarre(self.outfile, "Number of DC circuit breakers", "(ntfbkr)", ntfbkr)
            po.ovarre(self.outfile, "Number of dump resistors", "(ndumpr)", ndumpr)
            po.ovarre(
                self.outfile,
                "Resistance per dump resistor (ohm)",
                "(r1dump)",
                r1dump,
                "OP ",
            )
            po.ovarre(
                self.outfile, "Dump resistor peak power (MW)", "(r1ppmw)", r1ppmw, "OP "
            )
            po.ovarre(
                self.outfile,
                "Energy supplied per dump resistor (MJ)",
                "(r1emj)",
                r1emj,
                "OP ",
            )
            po.ovarre(
                self.outfile, "TF coil L/R time constant (s)", "(ttfsec)", ttfsec, "OP "
            )

            po.ovarre(self.outfile, "Power supply voltage (V)", "(tfpsv)", tfpsv, "OP ")
            po.ovarre(
                self.outfile, "Power supply current (kA)", "(tfpska)", tfpska, "OP "
            )
            po.ovarre(
                self.outfile, "DC power supply rating (kW)", "(tfckw)", tfckw, "OP "
            )
            po.ovarre(
                self.outfile, "AC power for charging (kW)", "(tfackw)", tfackw, "OP "
            )
            po.ovarre(
                self.outfile, "TF coil resistive power (MW)", "(rpower)", rpower, "OP "
            )

            po.ovarre(
                self.outfile, "TF coil inductive power (MVA)", "(xpower)", xpower, "OP "
            )
            po.ovarre(
                self.outfile, "Aluminium bus current density (kA/cm2)", "(djmka)", djmka
            )
            po.ovarre(
                self.outfile,
                "Aluminium bus cross-sectional area (cm2)",
                "(albusa)",
                albusa,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total length of TF coil bussing (m)",
                "(len_tf_bus)",
                len_tf_bus,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Aluminium bus weight (tonnes)",
                "(albuswt)",
                albuswt,
                "OP ",
            )

            po.ovarre(
                self.outfile,
                "Total TF coil bus resistance (ohm)",
                "(rtfbus)",
                rtfbus,
                "OP ",
            )
            po.ovarre(
                self.outfile, "TF coil bus voltage drop (V)", "(vtfbus)", vtfbus, "OP "
            )
            po.ovarre(
                self.outfile, "Dump resistor floor area (m2)", "(drarea)", drarea, "OP "
            )
            po.ovarre(
                self.outfile,
                "TF coil power conversion floor space (m2)",
                "(tfcfsp)",
                tfcfsp,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "TF coil power conv. building volume (m3)",
                "(tfcbv)",
                tfcbv,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "TF coil AC inductive power demand (MW)",
                "(xpwrmw)",
                xpwrmw,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total steady state AC power demand (MW)",
                "(p_tf_electric_supplies_mw)",
                p_tf_electric_supplies_mw,
                "OP ",
            )

        return (tfckw, len_tf_bus, drarea, tfcbv, p_tf_electric_supplies_mw)

    def power_profiles_over_time(
        self,
        t_precharge: float,
        t_current_ramp_up: float,
        t_fusion_ramp: float,
        t_burn: float,
        t_ramp_down: float,
        t_between_pulse: float,
        p_plant_electric_base_total_mw: float,
        p_cryo_plant_electric_mw: float,
        p_tritium_plant_electric_mw: float,
        vachtmw: float,
        p_tf_electric_supplies_mw: float,
        p_pf_electric_supplies_mw: float,
        p_coolant_pump_elec_total_mw: float,
        p_hcd_electric_total_mw: float,
        p_fusion_total_mw: float,
        p_plant_electric_gross_mw: float,
        p_plant_electric_net_mw: float,
    ) -> float:
        """Calculate time-dependent power profiles for different electric systems

        Parameters
        ----------
        t_precharge : float
            Precharge time (s).
        t_current_ramp_up : float
            Current ramp-up time (s).
        t_fusion_ramp : float
            Fusion ramp time (s).
        t_burn : float
            Burn time (s).
        t_ramp_down : float
            Ramp-down time (s).
        t_between_pulse : float
            Time between pulses (s).
        p_plant_electric_base_total_mw : float
            Plant base electric load (MW).
        p_cryo_plant_electric_mw : float
            Cryogenic plant electric load (MW).
        p_tritium_plant_electric_mw : float
            Tritium plant electric load (MW).
        vachtmw : float
            Vacuum pumps electric load (MW).
        p_tf_electric_supplies_mw : float
            TF coil electric supplies (MW).
        p_pf_electric_supplies_mw : float
            PF coil electric supplies (MW).
        p_coolant_pump_elec_total_mw : float
            Total coolant pump electric load (MW).
        p_hcd_electric_total_mw : float
            HCD electric total (MW).
        p_fusion_total_mw : float
            Fusion power (MW).
        p_plant_electric_gross_mw : float
            Gross electric power produced (MW).
        p_plant_electric_net_mw : float
            Net electric power produced (MW).

        Returns
        -------
        float
            Total net electric energy produced over the pulse (MJ).

        Notes
        -----
        - Assumes step-function changes in power at each phase transition.
        - Negative values indicate power consumption (loads).
        """

        t_steps = np.cumsum([
            0,
            t_precharge,
            t_current_ramp_up,
            t_fusion_ramp,
            t_burn,
            t_ramp_down,
            t_between_pulse,
        ])

        # Number of time steps
        n_steps = len(t_steps)

        # Initialize arrays for each power profile
        p_fusion_total_profile_mw = np.zeros(n_steps)
        p_plant_electric_base_total_profile_mw = np.zeros(n_steps)
        p_cryo_plant_electric_profile_mw = np.zeros(n_steps)
        p_tritium_plant_electric_profile_mw = np.zeros(n_steps)
        vachtmw_profile_mw = np.zeros(n_steps)
        p_tf_electric_supplies_profile_mw = np.zeros(n_steps)
        p_pf_electric_supplies_profile_mw = np.zeros(n_steps)
        p_coolant_pump_elec_total_profile_mw = np.zeros(n_steps)
        p_hcd_electric_total_profile_mw = np.zeros(n_steps)
        p_plant_electric_gross_profile_mw = np.zeros(n_steps)
        p_plant_electric_net_profile_mw = np.zeros(n_steps)

        # Fusion power: zero until ramp-up, then during burn
        p_fusion_total_profile_mw[:2] = 0
        p_fusion_total_profile_mw[2:5] = p_fusion_total_mw
        p_fusion_total_profile_mw[5:] = 0

        # Plant base load: constant negative load throughout
        p_plant_electric_base_total_profile_mw[:] = -p_plant_electric_base_total_mw

        # Cryo plant: constant negative load throughout
        p_cryo_plant_electric_profile_mw[:] = -p_cryo_plant_electric_mw

        # Tritium plant: constant negative load throughout
        p_tritium_plant_electric_profile_mw[:] = -p_tritium_plant_electric_mw

        # Vacuum pumps: constant negative load throughout
        vachtmw_profile_mw[:] = -vachtmw

        # TF coil supplies: assume coil is always charged, so constant negative load
        p_tf_electric_supplies_profile_mw[:] = -p_tf_electric_supplies_mw

        # PF coil supplies: zero for first step, then negative during ramp-up and burn, then zero
        p_pf_electric_supplies_profile_mw[0] = 0
        p_pf_electric_supplies_profile_mw[1:5] = -p_pf_electric_supplies_mw
        p_pf_electric_supplies_profile_mw[5:] = 0

        # Coolant pump elec total: zero for first two steps, then negative during ramp-up and burn, then zero
        p_coolant_pump_elec_total_profile_mw[:2] = 0
        p_coolant_pump_elec_total_profile_mw[2:5] = -p_coolant_pump_elec_total_mw
        p_coolant_pump_elec_total_profile_mw[5:] = 0

        # HCD electric total: zero for first two steps, then negative during ramp-up and burn, then zero
        p_hcd_electric_total_profile_mw[:2] = 0
        p_hcd_electric_total_profile_mw[2:5] = -p_hcd_electric_total_mw
        p_hcd_electric_total_profile_mw[5:] = 0

        # Gross electric power: zero for first two steps, then positive during burn, then zero
        p_plant_electric_gross_profile_mw[:2] = 0
        p_plant_electric_gross_profile_mw[2:5] = p_plant_electric_gross_mw
        p_plant_electric_gross_profile_mw[5:] = 0

        # Net electric power: calculated by subtracting all loads from gross electric power
        p_plant_electric_net_profile_mw = (
            p_plant_electric_gross_profile_mw
            + p_plant_electric_base_total_profile_mw
            + p_cryo_plant_electric_profile_mw
            + p_tritium_plant_electric_profile_mw
            + vachtmw_profile_mw
            + p_tf_electric_supplies_profile_mw
            + p_pf_electric_supplies_profile_mw
            + p_coolant_pump_elec_total_profile_mw
            + p_hcd_electric_total_profile_mw
        )

        if p_plant_electric_net_profile_mw[3] != p_plant_electric_net_mw:
            logger.error(
                "Calculated net electric power during burn does not match input value."
                f"Calculated: {p_plant_electric_net_profile_mw[3]}, Input: {p_plant_electric_net_mw}"
            )

        # Integrate net electric power over the pulse to get total energy produced (MJ)
        # Assume t_steps in seconds, power in MW, so energy in MJ
        energy_made_mj = sp.integrate.trapezoid(p_plant_electric_net_profile_mw, t_steps)
        energy_made_kwh = energy_made_mj / 3.6

        return (
            energy_made_kwh,
            energy_made_mj,
            p_plant_electric_base_total_profile_mw,
            p_plant_electric_gross_profile_mw,
            p_plant_electric_net_profile_mw,
            p_hcd_electric_total_profile_mw,
            p_coolant_pump_elec_total_profile_mw,
            p_tf_electric_supplies_profile_mw,
            p_pf_electric_supplies_profile_mw,
            vachtmw_profile_mw,
            p_tritium_plant_electric_profile_mw,
            p_cryo_plant_electric_profile_mw,
            p_fusion_total_profile_mw,
        )

    def output_power_profiles_over_time(
        self,
    ):
        for i, val in enumerate(power_variables.p_plant_electric_base_total_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric base load at time point {i}",
                f"(p_plant_electric_base_total_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_plant_electric_gross_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric gross at time point {i}",
                f"(p_plant_electric_gross_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_plant_electric_net_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric net at time point {i}",
                f"(p_plant_electric_net_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_hcd_electric_total_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric HCD at time point {i}",
                f"(p_hcd_electric_total_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_coolant_pump_elec_total_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric coolant pump at time point {i}",
                f"(p_coolant_pump_elec_total_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_tf_electric_supplies_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric TF supplies at time point {i}",
                f"(p_tf_electric_supplies_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_pf_electric_supplies_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric PF supplies at time point {i}",
                f"(p_pf_electric_supplies_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.vachtmw_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric vacuum pump power at time point {i}",
                f"(vachtmw_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_tritium_plant_electric_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric tritium plant power at time point {i}",
                f"(p_tritium_plant_electric_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_cryo_plant_electric_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric cryo plant power at time point {i}",
                f"(p_cryo_plant_electric_profile_mw{i})",
                val,
            )
        for i, val in enumerate(power_variables.p_fusion_total_profile_mw):
            po.ovarre(
                self.mfile,
                f"Plant total electric fusion plant power at time point {i}",
                f"(p_fusion_total_profile_mw{i})",
                val,
            )

outfile = constants.NOUT instance-attribute

mfile = constants.MFILE instance-attribute

pfpwr(output)

PF coil power supply requirements

outfile : input integer : output file unit iprint : input integer : switch for writing to output (1=yes) This routine calculates the MVA, power and energy requirements for the PF coil systems. Units are MW and MVA for power terms. The routine checks at the beginning of the flattop for the peak MVA, and at the end of flattop for the peak stored energy. The reactive (inductive) components use waves to calculate the dI/dt at the time periods. None

Parameters:

Name Type Description Default
output bool
required
Source code in process/models/power.py
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
def pfpwr(self, output: bool):
    """PF coil power supply requirements

    outfile : input integer : output file unit
    iprint : input integer : switch for writing to output (1=yes)
    This routine calculates the MVA, power and energy requirements
    for the PF coil systems.  Units are MW and MVA for power terms.
    The routine checks at the beginning of the flattop for the
    peak MVA, and at the end of flattop for the peak stored energy.
    The reactive (inductive) components use waves to calculate the
    <I>dI/dt</I> at the time periods.
    None

    Parameters
    ----------
    output: bool

    """
    powpfii = np.zeros((pfcoil_variables.NGC2,))
    cktr = np.zeros((pfcoil_variables.NGC2,))
    pfcr = np.zeros((pfcoil_variables.NGC2,))
    albusa = np.zeros((pfcoil_variables.NGC2,))
    pfbusr = np.zeros((pfcoil_variables.NGC2,))
    pfcr = np.zeros((pfcoil_variables.NGC2,))
    cktr = np.zeros((pfcoil_variables.NGC2,))
    rcktvm = np.zeros((pfcoil_variables.NGC2,))
    rcktpm = np.zeros((pfcoil_variables.NGC2,))
    vpfi = np.zeros((pfcoil_variables.NGC2,))
    psmva = np.zeros((pfcoil_variables.NGC2,))
    poloidalenergy = np.zeros((6,))
    inductxcurrent = np.zeros((6,))
    pfdissipation = np.zeros((5,))

    #  Bus length
    pfbusl = 8.0e0 * physics_variables.rmajor + 140.0e0

    #  Find power requirements for PF coils at times_variables.t_pulse_cumulative(ktim)

    #  PF coil resistive power requirements
    #  Bussing losses assume aluminium bussing with 100 A/cm**2
    ic = -1
    ngrpt = pfcoil_variables.n_pf_coil_groups
    if build_variables.iohcl != 0:
        ngrpt = ngrpt + 1

    pf_power_variables.srcktpm = 0.0e0
    pfbuspwr = 0.0e0

    for ig in range(ngrpt):
        ic = ic + pfcoil_variables.n_pf_coils_in_group[ig]

        #  Section area of aluminium bussing for circuit (cm**2)
        #  pfcoil_variables.c_pf_coil_turn_peak_input : max current per turn of coil (A)
        albusa[ig] = abs(pfcoil_variables.c_pf_coil_turn_peak_input[ic]) / 100.0e0

        #  Resistance of bussing for circuit (ohm)
        #  pfbusl : bus length for each PF circuit (m)
        #  pfbusr[ig] = 1.5e0 * 2.62e-4 * pfbusl / albusa[ig]
        #  I have removed the fudge factor of 1.5 but included it in the value of rhopfbus
        pfbusr[ig] = pfcoil_variables.rhopfbus * pfbusl / (albusa[ig] / 10000)

        #  Total PF coil resistance (during burn)
        #  pfcoil_variables.c_pf_cs_coils_peak_ma : maximum current in coil (A)
        pfcr[ig] = (
            pfcoil_variables.rho_pf_coil
            * 2.0e0
            * np.pi
            * pfcoil_variables.r_pf_coil_middle[ic]
            * abs(
                pfcoil_variables.j_pf_coil_wp_peak[ic]
                / (
                    (1.0e0 - pfcoil_variables.f_a_pf_coil_void[ic])
                    * 1.0e6
                    * pfcoil_variables.c_pf_cs_coils_peak_ma[ic]
                )
            )
            * pfcoil_variables.n_pf_coil_turns[ic] ** 2
            * pfcoil_variables.n_pf_coils_in_group[ig]
        )

        cktr[ig] = pfcr[ig] + pfbusr[ig]  # total resistance of circuit (ohms)
        cptburn = (
            pfcoil_variables.c_pf_coil_turn_peak_input[ic]
            * pfcoil_variables.c_pf_cs_coil_pulse_end_ma[ic]
            / pfcoil_variables.c_pf_cs_coils_peak_ma[ic]
        )
        rcktvm[ig] = abs(cptburn) * cktr[ig]  # peak resistive voltage (V)
        rcktpm[ig] = 1.0e-6 * rcktvm[ig] * abs(cptburn)  # peak resistive power (MW)

        #  Compute the sum of resistive power in the PF circuits, kW
        pfbuspwr = pfbuspwr + 1.0e-3 * pfbusr[ig] * cptburn**2
        pf_power_variables.srcktpm = pf_power_variables.srcktpm + 1.0e3 * rcktpm[ig]

    #  Inductive MVA requirements, and stored energy
    delktim = times_variables.t_plant_pulse_plasma_current_ramp_up

    #  PF system (including Central Solenoid solenoid) inductive MVA requirements
    #  pfcoil_variables.c_pf_coil_turn(i,j) : current per turn of coil i at (end) time period j (A)
    powpfi = 0.0e0
    powpfr = 0.0e0
    powpfr2 = 0.0e0

    #  pfcoil_variables.n_pf_cs_plasma_circuits : total number of PF coils (including Central Solenoid and plasma)
    #          plasma is #n_pf_cs_plasma_circuits, and Central Solenoid is #(pfcoil_variables.n_pf_cs_plasma_circuits-1)
    #  pfcoil_variables.ind_pf_cs_plasma_mutual(i,j) : mutual inductance between coil i and j
    for i in range(pfcoil_variables.n_pf_cs_plasma_circuits):
        powpfii[i] = 0.0e0
        vpfi[i] = 0.0e0

    jpf = -1
    poloidalenergy[:] = 0.0e0
    for jjpf in range(ngrpt):  # Loop over all groups of PF coils.
        for _jjpf2 in range(
            pfcoil_variables.n_pf_coils_in_group[jjpf]
        ):  # Loop over all coils in each group
            jpf = jpf + 1
            inductxcurrent[:] = 0.0e0
            for ipf in range(pfcoil_variables.n_pf_cs_plasma_circuits):
                #  Voltage in circuit jpf due to change in current from circuit ipf
                vpfij = (
                    pfcoil_variables.ind_pf_cs_plasma_mutual[jpf, ipf]
                    * (
                        pfcoil_variables.c_pf_coil_turn[ipf, 2]
                        - pfcoil_variables.c_pf_coil_turn[ipf, 1]
                    )
                    / delktim
                )

                #  Voltage in circuit jpf at time, times_variables.t_pulse_cumulative(3), due to changes in coil currents
                vpfi[jpf] = vpfi[jpf] + vpfij

                #  MVA in circuit jpf at time, times_variables.t_pulse_cumulative(3) due to changes in current
                powpfii[jpf] = (
                    powpfii[jpf]
                    + vpfij * pfcoil_variables.c_pf_coil_turn[jpf, 2] / 1.0e6
                )

                # Term used for calculating stored energy at each time
                for time in range(6):
                    inductxcurrent[time] = (
                        inductxcurrent[time]
                        + pfcoil_variables.ind_pf_cs_plasma_mutual[jpf, ipf]
                        * pfcoil_variables.c_pf_coil_turn[ipf, time]
                    )

                # engx = engx + pfcoil_variables.ind_pf_cs_plasma_mutual(jpf,ipf)*pfcoil_variables.c_pf_coil_turn(ipf,5)

            #  Stored magnetic energy of the poloidal field at each time
            # 'time' is the time INDEX.  't_pulse_cumulative' is the time.
            for time in range(6):
                poloidalenergy[time] = (
                    poloidalenergy[time]
                    + 0.5e0
                    * inductxcurrent[time]
                    * pfcoil_variables.c_pf_coil_turn[jpf, time]
                )

            #   do time = 1,5
            #     # Mean rate of change of stored energy between time and time+1
            #     if(abs(times_variables.t_pulse_cumulative(time+1)-times_variables.t_pulse_cumulative(time)).gt.1.0e0) :
            #         pf_power_variables.poloidalpower(time) = (poloidalenergy(time+1)-poloidalenergy(time)) / (times_variables.t_pulse_cumulative(time+1)-times_variables.t_pulse_cumulative(time))
            #     else:
            #         # Flag when an interval is small or zero MDK 30/11/16
            #         pf_power_variables.poloidalpower(time) = 9.9e9
            #

            #   end do
            #   #engxpc = 0.5e0 * engx * pfcoil_variables.c_pf_coil_turn(jpf,5)
            #   #ensxpf = ensxpf + engxpc

            #  Resistive power in circuits at times times_variables.t_pulse_cumulative(3) and times_variables.t_pulse_cumulative(5) respectively (MW)
            powpfr = (
                powpfr
                + pfcoil_variables.n_pf_coil_turns[jpf]
                * pfcoil_variables.c_pf_coil_turn[jpf, 2]
                * cktr[jjpf]
                / 1.0e6
            )
            powpfr2 = (
                powpfr2
                + pfcoil_variables.n_pf_coil_turns[jpf]
                * pfcoil_variables.c_pf_coil_turn[jpf, 4]
                * cktr[jjpf]
                / 1.0e6
            )
            powpfi = powpfi + powpfii[jpf]

    for time in range(5):
        # Stored magnetic energy of the poloidal field at each time
        # 'time' is the time INDEX.  't_pulse_cumulative' is the time.
        # Mean rate of change of stored energy between time and time+1
        if (
            abs(
                times_variables.t_pulse_cumulative[time + 1]
                - times_variables.t_pulse_cumulative[time]
            )
            > 1.0e0
        ):
            pf_power_variables.poloidalpower[time] = (
                poloidalenergy[time + 1] - poloidalenergy[time]
            ) / (
                times_variables.t_pulse_cumulative[time + 1]
                - times_variables.t_pulse_cumulative[time]
            )
        else:
            # Flag when an interval is small or zero MDK 30/11/16
            pf_power_variables.poloidalpower[time] = 9.9e9

        # Electrical energy dissipated in PFC power supplies as they increase or decrease the poloidal field energy
        # This assumes that the energy storage in the PFC power supply is lossless and that currents
        # in the coils can be varied without loss when there is no change in the energy in the poloidal field.
        # Energy is dissipated only when energy moves into or out of the store in the power supply.
        # Issue #713
        pfdissipation[time] = abs(
            poloidalenergy[time + 1] - poloidalenergy[time]
        ) * (1.0e0 / pfcoil_variables.etapsu - 1.0e0)

    # Mean power dissipated
    # The flat top duration (time 4 to 5) is the denominator, as this is the time when electricity is generated.
    if (
        times_variables.t_pulse_cumulative[4] - times_variables.t_pulse_cumulative[3]
        > 1.0e0
    ):
        pfpower = sum(pfdissipation[:]) / (
            times_variables.t_pulse_cumulative[4]
            - times_variables.t_pulse_cumulative[3]
        )
    else:
        # Give up when an interval is small or zero.
        pfpower = 0.0e0

    pfpowermw = pfpower / 1.0e6

    #  Compute the maximum stored energy and the maximum dissipative
    #  energy in all the PF circuits over the entire cycle time, MJ
    # ensxpfm = 1.0e-6 * ensxpf
    pf_power_variables.ensxpfm = 1.0e-6 * max(poloidalenergy)
    # Peak absolute rate of change of stored energy in poloidal field (MW)
    pf_power_variables.peakpoloidalpower = (
        max(abs(pf_power_variables.poloidalpower)) / 1.0e6
    )

    #  Maximum total MVA requirements
    heat_transport_variables.peakmva = max((powpfr + powpfi), powpfr2)

    pf_power_variables.vpfskv = 20.0e0
    pf_power_variables.pfckts = (
        pfcoil_variables.n_pf_cs_plasma_circuits - 2
    ) + 6.0e0
    pf_power_variables.spfbusl = pfbusl * pf_power_variables.pfckts
    pf_power_variables.acptmax = 0.0e0
    pf_power_variables.spsmva = 0.0e0

    for jpf in range(pfcoil_variables.n_pf_cs_plasma_circuits - 1):
        #  Power supply MVA for each PF circuit
        psmva[jpf] = 1.0e-6 * abs(
            vpfi[jpf] * pfcoil_variables.c_pf_coil_turn_peak_input[jpf]
        )

        #  Sum of the power supply MVA of the PF circuits
        pf_power_variables.spsmva = pf_power_variables.spsmva + psmva[jpf]

        #  Average of the maximum currents in the PF circuits, kA
        pf_power_variables.acptmax = (
            pf_power_variables.acptmax
            + 1.0e-3
            * abs(pfcoil_variables.c_pf_coil_turn_peak_input[jpf])
            / pf_power_variables.pfckts
        )

    #  PF wall plug power dissipated in power supply for ohmic heating (MW)
    #  This is additional to that required for moving stored energy around
    # p_pf_electric_supplies_mw = physics_variables.p_plasma_ohmic_mw / pfcoil_variables.etapsu
    wall_plug_ohmicmw = physics_variables.p_plasma_ohmic_mw * (
        1.0e0 / pfcoil_variables.etapsu - 1.0e0
    )
    # Total mean wall plug power dissipated in PFC and CS power supplies.  Issue #713
    pfcoil_variables.p_pf_electric_supplies_mw = wall_plug_ohmicmw + pfpowermw

    #  Output Section
    if output == 0:
        return

    po.oheadr(self.outfile, "PF Coils and Central Solenoid: Power and Energy")
    po.ovarre(
        self.outfile,
        "Number of PF coil circuits",
        "(pfckts)",
        pf_power_variables.pfckts,
    )
    po.ovarre(
        self.outfile,
        "Sum of PF power supply ratings (MVA)",
        "(spsmva)",
        pf_power_variables.spsmva,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total PF coil circuit bus length (m)",
        "(spfbusl)",
        pf_power_variables.spfbusl,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total PF coil bus resistive power (kW)",
        "(pfbuspwr)",
        pfbuspwr,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total PF coil resistive power (kW)",
        "(srcktpm)",
        pf_power_variables.srcktpm,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Maximum PF coil voltage (kV)",
        "(vpfskv)",
        pf_power_variables.vpfskv,
    )
    po.ovarre(
        self.outfile,
        "Efficiency of transfer of PF stored energy into or out of storage",
        "(etapsu)",
        pfcoil_variables.etapsu,
    )
    po.ocmmnt(
        self.outfile,
        "(Energy is dissipated in PFC power supplies only when total PF energy increases or decreases.)",
    )

    po.ovarre(
        self.outfile,
        "Maximum stored energy in poloidal field (MJ)",
        "(ensxpfm)",
        pf_power_variables.ensxpfm,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Peak absolute rate of change of stored energy in poloidal field (MW)",
        "(peakpoloidalpower)",
        pf_power_variables.peakpoloidalpower,
        "OP ",
    )

    if (numerics.ioptimz > 0) and (numerics.active_constraints[65]):
        po.ovarre(
            self.outfile,
            "Max permitted abs rate of change of stored energy in poloidal field (MW)",
            "maxpoloidalpower",
            pf_power_variables.maxpoloidalpower,
        )

    if any(poloidalenergy < 0.0e0):
        po.oheadr(self.outfile, "ERROR Negative stored energy in poloidal field")
        logger.error(f"{'ERROR Negative stored energy in poloidal field'}")

    po.ocmmnt(self.outfile, "Energy stored in poloidal magnetic field :")
    po.oblnkl(self.outfile)

acpow(output)

AC power requirements

outfile : input integer : output file unit iprint : input integer : switch for writing to output (1=yes) The routine was drastically shortened on 23/01/90 (ORNL) from the original TETRA routine to provide only the total power needs for the plant. Included in STORAC in January 1992 by P.C. Shipe. None

Parameters:

Name Type Description Default
output bool
required
Source code in process/models/power.py
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
def acpow(self, output: bool):
    """AC power requirements


    outfile : input integer : output file unit
    iprint : input integer : switch for writing to output (1=yes)
    The routine was drastically shortened on 23/01/90 (ORNL) from the
    original TETRA routine to provide only the total power needs for
    the plant. Included in STORAC in January 1992 by P.C. Shipe.
    None

    Parameters
    ----------
    output: bool

    """
    ptfmw = heat_transport_variables.p_tf_electric_supplies_mw
    ppfmw = 1.0e-3 * pf_power_variables.srcktpm
    if pf_power_variables.i_pf_energy_storage_source == 2:
        ppfmw = ppfmw + heat_transport_variables.peakmva

    #  Power to plasma heating supplies, MW
    pheatingmw = (
        heat_transport_variables.p_hcd_electric_total_mw
    )  # Should be zero if i_plasma_ignited==1

    #  Power to cryogenic comp. motors, MW
    crymw = heat_transport_variables.p_cryo_plant_electric_mw

    #  Power to divertor coil supplies, MW
    bdvmw = 0.0e0

    #  Total pulsed power system load, MW
    heat_transport_variables.pacpmw = (
        ppfmw
        + bdvmw
        + ptfmw
        + crymw
        + heat_transport_variables.vachtmw
        + heat_transport_variables.p_coolant_pump_elec_total_mw
        + heat_transport_variables.p_tritium_plant_electric_mw
        + pheatingmw
    )

    #  Add contribution from motor-generator flywheels if these are part of
    #  the PF coil energy storage system
    if pf_power_variables.i_pf_energy_storage_source != 2:
        heat_transport_variables.pacpmw = (
            heat_transport_variables.pacpmw + heat_transport_variables.fmgdmw
        )

    # Estimate of the total low voltage power, MW
    # MDK No idea what this is - especially the last term
    # It is used in the old cost routine, so I will leave it in place.
    heat_transport_variables.tlvpmw = (
        heat_transport_variables.p_plant_electric_base_total_mw
        + heat_transport_variables.p_tritium_plant_electric_mw
        + heat_transport_variables.p_coolant_pump_elec_total_mw
        + heat_transport_variables.vachtmw
        + 0.5e0 * (crymw + ppfmw)
    )

    if output == 0:
        return

    #  Output section
    # po.oheadr(self.outfile,'AC Power')
    po.oheadr(self.outfile, "Electric Power Requirements")
    po.ovarre(self.outfile, "Divertor coil power supplies (MW)", "(bdvmw)", bdvmw)
    po.ovarre(self.outfile, "Cryoplant electric power (MW)", "(crymw)", crymw, "OP ")
    # po.ovarre(self.outfile,'Heat removed from cryogenic coils (MWth)','(helpow/1.0e6)',helpow/1.0e6)
    # po.ovarre(self.outfile,'MGF (motor-generator flywheel) units (MW)', '(fmgdmw)',fmgdmw)
    # po.ovarin(self.outfile,'Primary coolant pumps (MW)', '(i_blkt_coolant_type)',i_blkt_coolant_type)
    po.ovarre(
        self.outfile,
        "Primary coolant pumps (MW)",
        "(p_coolant_pump_elec_total_mw..)",
        heat_transport_variables.p_coolant_pump_elec_total_mw,
        "OP ",
    )

    po.ovarre(self.outfile, "PF coil power supplies (MW)", "(ppfmw)", ppfmw, "OP ")
    # po.ovarre(self.outfile,'Power/floor area (kW/m2)','(pkwpm2)',pkwpm2)
    po.ovarre(self.outfile, "TF coil power supplies (MW)", "(ptfmw)", ptfmw, "OP ")
    po.ovarre(
        self.outfile,
        "Plasma heating supplies (MW)",
        "(pheatingmw)",
        pheatingmw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Tritium processing (MW)",
        "(p_tritium_plant_electric_mw..)",
        heat_transport_variables.p_tritium_plant_electric_mw,
    )
    po.ovarre(
        self.outfile,
        "Vacuum pumps  (MW)",
        "(vachtmw..)",
        heat_transport_variables.vachtmw,
    )

    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total pulsed power (MW)",
        "(pacpmw)",
        heat_transport_variables.pacpmw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Total base power required at all times (MW)",
        "(p_plant_electric_base_total_mw)",
        heat_transport_variables.p_plant_electric_base_total_mw,
        "OP ",
    )

component_thermal_powers()

Calculates the first part of the heat transport and plant power balance constituents This routine calculates the first part of the heat transport and plant power balance constituents. None

Source code in process/models/power.py
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
def component_thermal_powers(self):
    """Calculates the first part of the heat transport
    and plant power balance constituents
    This routine calculates the first part of the heat transport
    and plant power balance constituents.
    None
    """
    if int(fwbs_variables.i_p_coolant_pumping) not in (2, 3):
        primary_pumping_variables.p_fw_blkt_coolant_pump_mw = (
            heat_transport_variables.p_fw_coolant_pump_mw
            + heat_transport_variables.p_blkt_coolant_pump_mw
        )

    #  Account for pump electrical inefficiencies. The coolant pumps are not assumed to be
    #  100% efficient so the electric power to run them is greater than the power deposited
    #  in the coolant.  The difference should be lost as secondary heat.

    power_variables.p_fw_blkt_coolant_pump_elec_mw = (
        primary_pumping_variables.p_fw_blkt_coolant_pump_mw
        / fwbs_variables.eta_coolant_pump_electric
    )
    power_variables.p_shld_coolant_pump_elec_mw = (
        heat_transport_variables.p_shld_coolant_pump_mw
        / fwbs_variables.eta_coolant_pump_electric
    )
    power_variables.p_div_coolant_pump_elec_mw = (
        heat_transport_variables.p_div_coolant_pump_mw
        / fwbs_variables.eta_coolant_pump_electric
    )

    # Secondary breeder coolant loop. Should return zero if not used.
    power_variables.p_blkt_breeder_pump_elec_mw = (
        heat_transport_variables.p_blkt_breeder_pump_mw
        / fwbs_variables.eta_coolant_pump_electric
    )

    # Total mechanical pump power needed (deposited in coolant)
    power_variables.p_coolant_pump_total_mw = (
        primary_pumping_variables.p_fw_blkt_coolant_pump_mw
        + heat_transport_variables.p_blkt_breeder_pump_mw
        + heat_transport_variables.p_shld_coolant_pump_mw
        + heat_transport_variables.p_div_coolant_pump_mw
    )

    # Minimum total electrical power for primary coolant pumps (MW)
    heat_transport_variables.p_coolant_pump_elec_total_mw = (
        power_variables.p_fw_blkt_coolant_pump_elec_mw
        + power_variables.p_blkt_breeder_pump_elec_mw
        + power_variables.p_shld_coolant_pump_elec_mw
        + power_variables.p_div_coolant_pump_elec_mw
    )

    #  Heat lost through pump power inefficiencies (MW)
    heat_transport_variables.p_coolant_pump_loss_total_mw = (
        heat_transport_variables.p_coolant_pump_elec_total_mw
        - power_variables.p_coolant_pump_total_mw
    )

    # Heat lost in power supplies for heating and current drive
    heat_transport_variables.p_hcd_electric_loss_mw = (
        heat_transport_variables.p_hcd_electric_total_mw
        - current_drive_variables.p_hcd_injected_total_mw
    )

    # Liquid metal breeder/coolant
    # Calculate fraction of blanket nuclear power deposited in liquid breeder / coolant
    if fwbs_variables.i_blkt_dual_coolant == 2:
        power_variables.p_blkt_liquid_breeder_heat_deposited_mw = (
            fwbs_variables.p_blkt_nuclear_heat_total_mw
            * fwbs_variables.f_nuc_pow_bz_liq
        ) + heat_transport_variables.p_blkt_breeder_pump_mw

    # Liquid breeder is circulated but does no cooling
    elif fwbs_variables.i_blkt_dual_coolant == 1:
        power_variables.p_blkt_liquid_breeder_heat_deposited_mw = (
            heat_transport_variables.p_blkt_breeder_pump_mw
        )

    # Liquid breeder also acts a coolant
    if int(fwbs_variables.i_blkt_dual_coolant) in [1, 2]:
        power_variables.p_fw_blkt_heat_deposited_mw = (
            fwbs_variables.p_fw_nuclear_heat_total_mw
            + fwbs_variables.p_fw_rad_total_mw
            + fwbs_variables.p_blkt_nuclear_heat_total_mw
            + heat_transport_variables.p_blkt_breeder_pump_mw
            + primary_pumping_variables.p_fw_blkt_coolant_pump_mw
            + current_drive_variables.p_beam_orbit_loss_mw
            + physics_variables.p_fw_alpha_mw
            + current_drive_variables.p_beam_shine_through_mw
        )
    else:
        # No secondary liquid metal breeder/coolant
        power_variables.p_fw_blkt_heat_deposited_mw = (
            fwbs_variables.p_fw_nuclear_heat_total_mw
            + fwbs_variables.p_fw_rad_total_mw
            + fwbs_variables.p_blkt_nuclear_heat_total_mw
            + primary_pumping_variables.p_fw_blkt_coolant_pump_mw
            + current_drive_variables.p_beam_orbit_loss_mw
            + physics_variables.p_fw_alpha_mw
            + current_drive_variables.p_beam_shine_through_mw
        )

    #  Total power deposited in first wall coolant (MW)
    power_variables.p_fw_heat_deposited_mw = (
        fwbs_variables.p_fw_nuclear_heat_total_mw
        + fwbs_variables.p_fw_rad_total_mw
        + heat_transport_variables.p_fw_coolant_pump_mw
        + current_drive_variables.p_beam_orbit_loss_mw
        + physics_variables.p_fw_alpha_mw
        + current_drive_variables.p_beam_shine_through_mw
    )

    #  Total power deposited in blanket coolant (MW)
    power_variables.p_blkt_heat_deposited_mw = (
        fwbs_variables.p_blkt_nuclear_heat_total_mw
        + heat_transport_variables.p_blkt_coolant_pump_mw
    )

    #  Total power deposited in shield coolant (MW)
    power_variables.p_shld_heat_deposited_mw = (
        fwbs_variables.p_cp_shield_nuclear_heat_mw
        + fwbs_variables.p_shld_nuclear_heat_mw
        + heat_transport_variables.p_shld_coolant_pump_mw
    )

    #  Total thermal power deposited in divertor (MW)
    power_variables.p_div_heat_deposited_mw = (
        physics_variables.p_plasma_separatrix_mw
        + (
            fwbs_variables.p_div_nuclear_heat_total_mw
            + fwbs_variables.p_div_rad_total_mw
        )
        + heat_transport_variables.p_div_coolant_pump_mw
    )

    #  Heat removal from first wall and divertor (MW) (only used in costs.f90)
    if fwbs_variables.i_p_coolant_pumping != 3:
        heat_transport_variables.p_fw_div_heat_deposited_mw = (
            power_variables.p_fw_heat_deposited_mw
            + power_variables.p_div_heat_deposited_mw
        )

    #  Thermal to electric efficiency
    heat_transport_variables.eta_turbine = self.plant_thermal_efficiency(
        heat_transport_variables.eta_turbine
    )
    heat_transport_variables.etath_liq = self.plant_thermal_efficiency_2(
        heat_transport_variables.etath_liq
    )

    #  Primary (high-grade) thermal power, available for electricity generation.  Switch heat_transport_variables.i_shld_primary_heat
    #  is 1 or 0, is user choice on whether the shield thermal power goes to primary or secondary heat
    if fwbs_variables.i_thermal_electric_conversion == 0:
        #  Primary thermal power (MW)
        heat_transport_variables.p_plant_primary_heat_mw = (
            power_variables.p_fw_blkt_heat_deposited_mw
            + heat_transport_variables.i_shld_primary_heat
            * power_variables.p_shld_heat_deposited_mw
        )
        #  Secondary thermal power deposited in divertor (MW)
        heat_transport_variables.p_div_secondary_heat_mw = (
            power_variables.p_div_heat_deposited_mw
        )
        # Divertor primary/secondary power switch: does NOT contribute to energy generation cycle
        power_variables.i_div_primary_heat = 0
    else:
        #  Primary thermal power used to generate electricity (MW)
        heat_transport_variables.p_plant_primary_heat_mw = (
            power_variables.p_fw_blkt_heat_deposited_mw
            + heat_transport_variables.i_shld_primary_heat
            * power_variables.p_shld_heat_deposited_mw
            + power_variables.p_div_heat_deposited_mw
        )
        #  Secondary thermal power deposited in divertor (MW)
        heat_transport_variables.p_div_secondary_heat_mw = 0.0e0
        # Divertor primary/secondary power switch: contributes to energy generation cycle
        power_variables.i_div_primary_heat = 1

    if abs(heat_transport_variables.p_plant_primary_heat_mw) < 1.0e-4:
        logger.error(f"{'ERROR Primary thermal power is zero or negative'}")

    # #284 Fraction of total high-grade thermal power to divertor
    power_variables.f_p_div_primary_heat = (
        power_variables.p_div_heat_deposited_mw
        / heat_transport_variables.p_plant_primary_heat_mw
    )
    # Loss in efficiency as this primary power is collecetd at very low temperature
    power_variables.delta_eta = 0.339 * power_variables.f_p_div_primary_heat

    # ===============================================
    #  Secondary thermal powers
    # ================================================

    #  Secondary thermal power deposited in shield
    heat_transport_variables.p_shld_secondary_heat_mw = (
        power_variables.p_shld_heat_deposited_mw
        * (1 - heat_transport_variables.i_shld_primary_heat)
    )

    #  Secondary thermal power lost to HCD apparatus and diagnostics
    heat_transport_variables.p_hcd_secondary_heat_mw = (
        fwbs_variables.p_fw_hcd_nuclear_heat_mw
        + fwbs_variables.p_fw_hcd_rad_total_mw
    )

    #  Number of primary heat exchangers
    heat_transport_variables.n_primary_heat_exchangers = math.ceil(
        heat_transport_variables.p_plant_primary_heat_mw / 1000.0e0
    )

calculate_cryo_loads()

Calculates and updates the cryogenic heat loads for the system.

This method computes the various cryogenic heat loads, including conduction/radiation, nuclear heating, AC losses, and resistive losses in current leads. It also updates the miscellaneous allowance and total heat removal at cryogenic temperatures. The results are stored in the corresponding instance variables.

Source code in process/models/power.py
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
def calculate_cryo_loads(self):
    """Calculates and updates the cryogenic heat loads for the system.

    This method computes the various cryogenic heat loads, including conduction/radiation,
    nuclear heating, AC losses, and resistive losses in current leads. It also updates
    the miscellaneous allowance and total heat removal at cryogenic temperatures.
    The results are stored in the corresponding instance variables.
    """

    #  Cryogenic power
    # ---
    # Initialisation (unchanged if all coil resisitive)
    heat_transport_variables.helpow = 0.0e0
    heat_transport_variables.p_cryo_plant_electric_mw = 0.0e0
    p_tf_cryoal_cryo = 0.0e0
    tfcoil_variables.cryo_cool_req = 0.0e0

    # Superconductors TF/PF cryogenic cooling
    if tfcoil_variables.i_tf_sup == 1 or pfcoil_variables.i_pf_conductor == 0:
        # heat_transport_variables.helpow calculation
        heat_transport_variables.helpow = self.cryo(
            tfcoil_variables.i_tf_sup,
            tfcoil_variables.tfcryoarea,
            structure_variables.coldmass,
            fwbs_variables.p_tf_nuclear_heat_mw,
            pf_power_variables.ensxpfm,
            times_variables.t_plant_pulse_plasma_present,
            tfcoil_variables.c_tf_turn,
            tfcoil_variables.n_tf_coils,
        )

        # Use 13% of ideal Carnot efficiency to fit J. Miller estimate
        # Rem SK : This ITER efficiency is very low compare to the Strowbridge curve
        #          any reasons why?
        # Calculate electric power requirement for cryogenic plant at tfcoil_variables.temp_tf_cryo (MW)
        heat_transport_variables.p_cryo_plant_electric_mw = (
            1.0e-6
            * (constants.TEMP_ROOM - tfcoil_variables.temp_tf_cryo)
            / (tfcoil_variables.eff_tf_cryo * tfcoil_variables.temp_tf_cryo)
            * heat_transport_variables.helpow
        )

    # Cryogenic alumimium
    # Rem : The carnot efficiency is assumed at 40% as this is a conservative assumption since a 50%
    #       has been deduced from detailed studies
    # Rem : Nuclear heating on the outer legs assumed to be negligible
    # Rem : To be updated with 2 cooling loops for TART designs
    if tfcoil_variables.i_tf_sup == 2:
        # Heat removal power at cryogenic temperature tfcoil_variables.temp_cp_coolant_inlet (W)
        heat_transport_variables.helpow_cryal = (
            tfcoil_variables.p_cp_resistive
            + tfcoil_variables.p_tf_leg_resistive
            + tfcoil_variables.p_tf_joints_resistive
            + fwbs_variables.pnuc_cp_tf * 1.0e6
        )

        # Calculate electric power requirement for cryogenic plant at tfcoil_variables.temp_cp_coolant_inlet (MW)
        p_tf_cryoal_cryo = (
            1.0e-6
            * (constants.TEMP_ROOM - tfcoil_variables.temp_cp_coolant_inlet)
            / (tfcoil_variables.eff_tf_cryo * tfcoil_variables.temp_cp_coolant_inlet)
            * heat_transport_variables.helpow_cryal
        )

        # Add to electric power requirement for cryogenic plant (MW)
        heat_transport_variables.p_cryo_plant_electric_mw = (
            heat_transport_variables.p_cryo_plant_electric_mw + p_tf_cryoal_cryo
        )

    # Calculate cryo cooling requirement at 4.5K (kW)
    tfcoil_variables.cryo_cool_req = (
        heat_transport_variables.helpow
        * ((293 / tfcoil_variables.temp_tf_cryo) - 1)
        / ((293 / 4.5) - 1)
        + heat_transport_variables.helpow_cryal
        * ((293 / tfcoil_variables.temp_cp_coolant_inlet) - 1)
        / ((293 / 4.5) - 1)
    ) / 1.0e3

output_plant_thermal_powers()

Source code in process/models/power.py
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
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
1058
1059
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
def output_plant_thermal_powers(self):
    po.oheadr(self.outfile, "Plant Heat Transport Balance")

    po.ocmmnt(self.outfile, "First Wall : ")
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heat deposited in FW [MW]",
        "(p_fw_nuclear_heat_total_mw)",
        fwbs_variables.p_fw_nuclear_heat_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Radiation heat deposited in FW [MW]",
        "(p_fw_rad_total_mw)",
        fwbs_variables.p_fw_rad_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Lost alpha-particle heat deposited in FW [MW]",
        "(p_fw_alpha_mw)",
        physics_variables.p_fw_alpha_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutral beam shine-through heat deposited in FW [MW]",
        "(p_beam_shine_through_mw)",
        current_drive_variables.p_beam_shine_through_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutral beam orbit loss heat deposited in FW [MW]",
        "(p_beam_orbit_loss_mw)",
        current_drive_variables.p_beam_orbit_loss_mw,
    )

    po.ovarre(
        self.outfile,
        "Mechancial pumping power deposited in FW coolant [MW]",
        "(p_fw_coolant_pump_mw)",
        heat_transport_variables.p_fw_coolant_pump_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total heat deposited in FW and coolant [MW]",
        "(p_fw_heat_deposited_mw)",
        power_variables.p_fw_heat_deposited_mw,
    )
    po.oblnkl(self.outfile)

    po.ocmmnt(self.outfile, "Blanket : ")
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total neutronic nuclear heat deposited and created in Blanket(s) [MW]",
        "(p_blkt_nuclear_heat_total_mw)",
        fwbs_variables.p_blkt_nuclear_heat_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Total multiplication neutronic nuclear heat created in Blanket(s) [MW]",
        "(p_blkt_multiplication_mw)",
        fwbs_variables.p_blkt_multiplication_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutron nuclear heat multiplication factor in Blanket(s)",
        "(f_p_blkt_multiplication)",
        fwbs_variables.f_p_blkt_multiplication,
    )

    po.ovarre(
        self.outfile,
        "Mechancial pumping power deposited in Blanket(s) coolant [MW]",
        "(p_blkt_coolant_pump_mw)",
        heat_transport_variables.p_blkt_coolant_pump_mw,
    )

    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total heat deposited in Blanket(s) and coolant [MW]",
        "(p_blkt_heat_deposited_mw)",
        power_variables.p_blkt_heat_deposited_mw,
    )

    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "FW and Blanket : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Mechancial pumping power deposited in Blanket(s) and FW coolant [MW]",
        "(p_fw_blkt_coolant_pump_mw)",
        primary_pumping_variables.p_fw_blkt_coolant_pump_mw,
    )
    po.ovarre(
        self.outfile,
        "Total heat deposited in Blanket(s) and FW coolant [MW]",
        "(p_fw_blkt_heat_deposited_mw)",
        power_variables.p_fw_blkt_heat_deposited_mw,
    )

    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "VV and Shield : ")
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heat deposited in VV shield [MW]",
        "(p_shld_nuclear_heat_mw)",
        fwbs_variables.p_shld_nuclear_heat_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heat deposited in ST centrepost shield [MW]",
        "(p_cp_shield_nuclear_heat_mw)",
        fwbs_variables.p_cp_shield_nuclear_heat_mw,
    )

    po.ovarre(
        self.outfile,
        "Mechancial pumping power deposited in shield coolant(s) [MW]",
        "(p_shld_coolant_pump_mw)",
        heat_transport_variables.p_shld_coolant_pump_mw,
    )

    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total heat deposited in VV and shield coolant(s) [MW]",
        "(p_shld_heat_deposited_mw)",
        power_variables.p_shld_heat_deposited_mw,
    )

    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "Divertor : ")
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Plasma separatrix power deposited in divertor [MW]",
        "(p_plasma_separatrix_mw)",
        physics_variables.p_plasma_separatrix_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heat deposited in divertor [MW]",
        "(p_div_nuclear_heat_total_mw)",
        fwbs_variables.p_div_nuclear_heat_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Radiation heat deposited in divertor [MW]",
        "(p_div_rad_total_mw)",
        fwbs_variables.p_div_rad_total_mw,
    )

    po.ovarre(
        self.outfile,
        "Mechancial pumping power deposited in divertor coolant [MW]",
        "(p_div_coolant_pump_mw)",
        heat_transport_variables.p_div_coolant_pump_mw,
    )

    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total heat deposited in divertor and coolants [MW]",
        "(p_div_heat_deposited_mw)",
        power_variables.p_div_heat_deposited_mw,
    )

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

    po.ovarre(
        self.outfile,
        "Mechanical pumping power of all coolant pumps [MW]",
        "(p_coolant_pump_total_mw)",
        power_variables.p_coolant_pump_total_mw,
    )

    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "Secondary heat : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Electric power for core plant systems [MW]",
        "(p_plant_core_systems_elec_mw)",
        power_variables.p_plant_core_systems_elec_mw,
    )
    po.ovarre(
        self.outfile,
        "Wall plug losses in H&CD systems [MW]",
        "(p_hcd_electric_loss_mw)",
        heat_transport_variables.p_hcd_electric_loss_mw,
    )
    po.ovarre(
        self.outfile,
        "Total wall plug losses in coolant pump systems [MW]",
        "(p_coolant_pump_loss_total_mw)",
        heat_transport_variables.p_coolant_pump_loss_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Divertor thermal power not used for electricity production [MW]",
        "(p_div_secondary_heat_mw)",
        heat_transport_variables.p_div_secondary_heat_mw,
    )
    po.ovarre(
        self.outfile,
        "Shield thermal power not used for electricity production [MW]",
        "(p_shld_secondary_heat_mw)",
        heat_transport_variables.p_shld_secondary_heat_mw,
    )
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heating in TF coils [MW]",
        "(p_tf_nuclear_heat_mw)",
        fwbs_variables.p_tf_nuclear_heat_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Neutronic nuclear heating in H&CD systems and diagnostics [MW]",
        "(p_fw_hcd_nuclear_heat_mw)",
        fwbs_variables.p_fw_hcd_nuclear_heat_mw,
    )
    po.ovarre(
        self.outfile,
        "Radiation heat deposited in H&CD systems and diagnostics [MW]",
        "(p_fw_hcd_rad_total_mw)",
        fwbs_variables.p_fw_hcd_rad_total_mw,
    )
    po.ovarre(
        self.outfile,
        "Total heat deposited in in H&CD systems and diagnostics [MW]",
        "(p_hcd_secondary_heat_mw)",
        heat_transport_variables.p_hcd_secondary_heat_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total secondary heat not used for electricity production [MW]",
        "(p_plant_secondary_heat_mw)",
        heat_transport_variables.p_plant_secondary_heat_mw,
    )

    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "Primary heat : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total heat deposited in FW and coolant [MW]",
        "(p_fw_heat_deposited_mw)",
        power_variables.p_fw_heat_deposited_mw,
    )
    po.ovarre(
        self.outfile,
        "Total heat deposited in Blanket(s) and coolant [MW]",
        "(p_blkt_heat_deposited_mw)",
        power_variables.p_blkt_heat_deposited_mw,
    )
    po.ovarre(
        self.outfile,
        "Total heat deposited in Blanket(s) and FW coolant [MW]",
        "(p_fw_blkt_heat_deposited_mw)",
        power_variables.p_fw_blkt_heat_deposited_mw,
    )
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total heat deposited in VV and shield coolant(s) [MW]",
        "(p_shld_heat_deposited_mw)",
        power_variables.p_shld_heat_deposited_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total heat deposited in divertor and coolants [MW]",
        "(p_div_heat_deposited_mw)",
        power_variables.p_div_heat_deposited_mw,
    )
    po.ovarre(
        self.outfile,
        "Fraction of total primary heat originating from divertor",
        "(f_p_div_primary_heat)",
        power_variables.f_p_div_primary_heat,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total primary thermal power used for electricity production [MW]",
        "(p_plant_primary_heat_mw)",
        heat_transport_variables.p_plant_primary_heat_mw,
    )

output_plant_electric_powers()

Source code in process/models/power.py
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
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
def output_plant_electric_powers(self):
    po.oheadr(self.outfile, "Plant Electricity Production")

    po.ocmmnt(self.outfile, "Turbine conversion : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total high grade thermal power used for electricity production [MWth]",
        "(p_plant_primary_heat_mw)",
        heat_transport_variables.p_plant_primary_heat_mw,
    )

    po.ovarrf(
        self.outfile,
        "Thermal to electric conversion efficiency of the turbine",
        "(eta_turbine)",
        heat_transport_variables.eta_turbine,
    )
    po.ovarre(
        self.outfile,
        "Total thermal power lost in power conversion [MWth]",
        "(p_turbine_loss_mw)",
        power_variables.p_turbine_loss_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total electric power produced [MWe]",
        "(p_plant_electric_gross_mw)",
        heat_transport_variables.p_plant_electric_gross_mw,
    )
    po.oblnkl(self.outfile)
    po.ocmmnt(self.outfile, "----------------------------")
    po.oblnkl(self.outfile)

    po.ocmmnt(self.outfile, "Electric requirements of core plant systems : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Base plant electric load [We]",
        "(p_plant_electric_base)",
        heat_transport_variables.p_plant_electric_base,
    )
    po.ovarre(
        self.outfile,
        "Electric power per unit area of plant floor space [We/m^2]",
        "(pflux_plant_floor_electric)",
        heat_transport_variables.pflux_plant_floor_electric,
    )
    po.ovarre(
        self.outfile,
        "Effective area of plant buildings floor [m^2]",
        "(a_plant_floor_effective)",
        buildings_variables.a_plant_floor_effective,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total base plant electric load [MWe]",
        "(p_plant_electric_base_total_mw)",
        heat_transport_variables.p_plant_electric_base_total_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Electric power demand for cryo plant [MWe]",
        "(p_cryo_plant_electric_mw)",
        heat_transport_variables.p_cryo_plant_electric_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand for tritium plant [MWe]",
        "(p_tritium_plant_electric_mw)",
        heat_transport_variables.p_tritium_plant_electric_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand for vacuum pumps [MWe]",
        "(vachtmw)",
        heat_transport_variables.vachtmw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand for TF coil system [MWe]",
        "(p_tf_electric_supplies_mw)",
        heat_transport_variables.p_tf_electric_supplies_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand for PF coil system [MWe]",
        "(p_pf_electric_supplies_mw)",
        pfcoil_variables.p_pf_electric_supplies_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand for CP coolant pumps [MWe]",
        "(p_cp_coolant_pump_elec_mw)",
        power_variables.p_cp_coolant_pump_elec_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Electric power demand of core plant systems needed at all times [MWe]",
        "(p_plant_core_systems_elec_mw)",
        power_variables.p_plant_core_systems_elec_mw,
    )

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

    po.ocmmnt(self.outfile, "Electric requirements during plasma flat-top : ")
    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Electric power demand of FW and Blanket coolant pumps [MWe]",
        "(p_fw_blkt_coolant_pump_elec_mw)",
        power_variables.p_fw_blkt_coolant_pump_elec_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand of Blanket secondary breeder coolant pumps [MWe]",
        "(p_blkt_breeder_pump_elec_mw)",
        power_variables.p_blkt_breeder_pump_elec_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand of VV and Shield coolant pumps [MWe]",
        "(p_shld_coolant_pump_elec_mw)",
        power_variables.p_shld_coolant_pump_elec_mw,
    )
    po.ovarre(
        self.outfile,
        "Electric power demand of Divertor colant pumps [MWe]",
        "(p_div_coolant_pump_elec_mw)",
        power_variables.p_div_coolant_pump_elec_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Electric wall plug efficiency of coolant pumps",
        "(eta_coolant_pump_electric)",
        fwbs_variables.eta_coolant_pump_electric,
    )
    po.ovarre(
        self.outfile,
        "Total electric demand of all coolant pumps [MWe]",
        "(p_coolant_pump_elec_total_mw)",
        heat_transport_variables.p_coolant_pump_elec_total_mw,
    )
    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Total electric demand of all H&CD systems [MWe]",
        "(p_hcd_electric_total_mw)",
        heat_transport_variables.p_hcd_electric_total_mw,
    )

    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total re-circulated electric power of the plant [MWe]",
        "(p_plant_electric_recirc_mw)",
        heat_transport_variables.p_plant_electric_recirc_mw,
    )
    po.ovarre(
        self.outfile,
        "Fraction of gross electricity re-circulated",
        "(f_p_plant_electric_recirc)",
        heat_transport_variables.f_p_plant_electric_recirc,
    )

    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total net-electric power of the plant [MWe]",
        "(p_plant_electric_net_mw)",
        heat_transport_variables.p_plant_electric_net_mw,
    )

    po.oblnkl(self.outfile)

    po.ovarre(
        self.outfile,
        "Total electric energy output per pulse (MJ)",
        "(e_plant_net_electric_pulse_mj)",
        power_variables.e_plant_net_electric_pulse_mj,
    )
    po.ovarre(
        self.outfile,
        "Total electric energy output per pulse (kWh)",
        "(e_plant_net_electric_pulse_kwh)",
        power_variables.e_plant_net_electric_pulse_kwh,
    )

plant_electric_production()

This method completes the calculation of the plant's electrical and thermal power flows, including secondary heat, recirculating power, net and gross electric power, and various efficiency measures.

If output is True, the method writes a comprehensive summary of the plant's power and heat transport balance, assumptions, and efficiency metrics to the specified output file.

Source code in process/models/power.py
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
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
def plant_electric_production(self):
    """This method completes the calculation of the plant's electrical and thermal power flows,
    including secondary heat, recirculating power, net and gross electric power, and various
    efficiency measures.

    If `output` is True, the method writes a comprehensive summary of the plant's power and
    heat transport balance, assumptions, and efficiency metrics to the specified output file.
    """
    if physics_variables.itart == 1 and tfcoil_variables.i_tf_sup == 0:
        power_variables.p_cp_coolant_pump_elec_mw = (
            1.0e-6 * tfcoil_variables.p_cp_coolant_pump_elec
        )
    else:
        power_variables.p_cp_coolant_pump_elec_mw = 0.0e0

    #  Total baseline power to facility loads, MW
    heat_transport_variables.p_plant_electric_base_total_mw = (
        heat_transport_variables.p_plant_electric_base * 1.0e-6
        + buildings_variables.a_plant_floor_effective
        * (heat_transport_variables.pflux_plant_floor_electric * 1.0e-3)
        / 1000.0e0
    )

    #  Facility heat removal (heat_transport_variables.p_plant_electric_base_total_mw calculated in ACPOW)
    heat_transport_variables.fachtmw = (
        heat_transport_variables.p_plant_electric_base_total_mw
    )

    #  Electrical power consumed by fusion power core systems
    #  (excluding heat transport pumps and auxiliary injection power system)

    power_variables.p_plant_core_systems_elec_mw = (
        heat_transport_variables.p_cryo_plant_electric_mw
        + heat_transport_variables.fachtmw
        + power_variables.p_cp_coolant_pump_elec_mw
        + heat_transport_variables.p_tf_electric_supplies_mw
        + heat_transport_variables.p_tritium_plant_electric_mw
        + heat_transport_variables.vachtmw
        + pfcoil_variables.p_pf_electric_supplies_mw
    )

    #  Total secondary heat
    #  (total low-grade heat rejected - does not contribute to power conversion cycle)
    #  Included fwbs_variables.p_tf_nuclear_heat_mw
    # p_plant_secondary_heat_mw = power_variables.p_plant_core_systems_elec_mw + heat_transport_variables.p_hcd_electric_loss_mw + heat_transport_variables.p_coolant_pump_loss_total_mw + hthermmw + heat_transport_variables.p_div_secondary_heat_mw + heat_transport_variables.p_shld_secondary_heat_mw + heat_transport_variables.p_hcd_secondary_heat_mw + fwbs_variables.p_tf_nuclear_heat_mw
    heat_transport_variables.p_plant_secondary_heat_mw = (
        power_variables.p_plant_core_systems_elec_mw
        + heat_transport_variables.p_hcd_electric_loss_mw
        + heat_transport_variables.p_coolant_pump_loss_total_mw
        + heat_transport_variables.p_div_secondary_heat_mw
        + heat_transport_variables.p_shld_secondary_heat_mw
        + heat_transport_variables.p_hcd_secondary_heat_mw
        + fwbs_variables.p_tf_nuclear_heat_mw
    )

    #  Calculate powers relevant to a power-producing plant
    if cost_variables.ireactor == 1:
        #  Gross electric power
        # p_plant_electric_gross_mw = (heat_transport_variables.p_plant_primary_heat_mw-hthermmw) * heat_transport_variables.eta_turbine
        if (
            fwbs_variables.i_blkt_dual_coolant > 0
            and fwbs_variables.i_p_coolant_pumping == 2
        ):
            heat_transport_variables.p_plant_electric_gross_mw = (
                (
                    heat_transport_variables.p_plant_primary_heat_mw
                    - power_variables.p_blkt_liquid_breeder_heat_deposited_mw
                )
                * heat_transport_variables.eta_turbine
                + power_variables.p_blkt_liquid_breeder_heat_deposited_mw
                * heat_transport_variables.etath_liq
            )
        else:
            heat_transport_variables.p_plant_electric_gross_mw = (
                heat_transport_variables.p_plant_primary_heat_mw
                * heat_transport_variables.eta_turbine
            )

        # Total lost thermal power in the turbine
        power_variables.p_turbine_loss_mw = (
            heat_transport_variables.p_plant_primary_heat_mw
            * (1 - heat_transport_variables.eta_turbine)
        )

        #  Total recirculating power
        heat_transport_variables.p_plant_electric_recirc_mw = (
            power_variables.p_plant_core_systems_elec_mw
            + heat_transport_variables.p_hcd_electric_total_mw
            + heat_transport_variables.p_coolant_pump_elec_total_mw
        )

        #  Net electric power
        heat_transport_variables.p_plant_electric_net_mw = (
            heat_transport_variables.p_plant_electric_gross_mw
            - heat_transport_variables.p_plant_electric_recirc_mw
        )

        #  Recirculating power fraction
        heat_transport_variables.f_p_plant_electric_recirc = (
            heat_transport_variables.p_plant_electric_gross_mw
            - heat_transport_variables.p_plant_electric_net_mw
        ) / heat_transport_variables.p_plant_electric_gross_mw

    (
        power_variables.e_plant_net_electric_pulse_kwh,
        power_variables.e_plant_net_electric_pulse_mj,
        power_variables.p_plant_electric_base_total_profile_mw,
        power_variables.p_plant_electric_gross_profile_mw,
        power_variables.p_plant_electric_net_profile_mw,
        power_variables.p_hcd_electric_total_profile_mw,
        power_variables.p_coolant_pump_elec_total_profile_mw,
        power_variables.p_tf_electric_supplies_profile_mw,
        power_variables.p_pf_electric_supplies_profile_mw,
        power_variables.vachtmw_profile_mw,
        power_variables.p_tritium_plant_electric_profile_mw,
        power_variables.p_cryo_plant_electric_profile_mw,
        power_variables.p_fusion_total_profile_mw,
    ) = self.power_profiles_over_time(
        t_precharge=times_variables.t_plant_pulse_coil_precharge,
        t_current_ramp_up=times_variables.t_plant_pulse_plasma_current_ramp_up,
        t_fusion_ramp=times_variables.t_plant_pulse_fusion_ramp,
        t_burn=times_variables.t_plant_pulse_burn,
        t_ramp_down=times_variables.t_plant_pulse_plasma_current_ramp_down,
        t_between_pulse=times_variables.t_plant_pulse_dwell,
        p_plant_electric_base_total_mw=heat_transport_variables.p_plant_electric_base_total_mw,
        p_cryo_plant_electric_mw=heat_transport_variables.p_cryo_plant_electric_mw,
        p_tritium_plant_electric_mw=heat_transport_variables.p_tritium_plant_electric_mw,
        vachtmw=heat_transport_variables.vachtmw,
        p_tf_electric_supplies_mw=heat_transport_variables.p_tf_electric_supplies_mw,
        p_pf_electric_supplies_mw=pfcoil_variables.p_pf_electric_supplies_mw,
        p_coolant_pump_elec_total_mw=heat_transport_variables.p_coolant_pump_elec_total_mw,
        p_hcd_electric_total_mw=heat_transport_variables.p_hcd_electric_total_mw,
        p_fusion_total_mw=physics_variables.p_fusion_total_mw,
        p_plant_electric_gross_mw=heat_transport_variables.p_plant_electric_gross_mw,
        p_plant_electric_net_mw=heat_transport_variables.p_plant_electric_net_mw,
    )

cryo(i_tf_sup, tfcryoarea, coldmass, p_tf_nuclear_heat_mw, ensxpfm, t_plant_pulse_plasma_present, c_tf_turn, n_tf_coils)

Calculates cryogenic loads

itfsup : input integer : Switch denoting whether TF coils are superconducting tfcryoarea : input real : Surface area of toroidal shells covering TF coils (m2) coldmass : input real : Mass of cold (cryogenic) components (kg), including TF coils, PF coils, cryostat, and intercoil structure p_tf_nuclear_heat_mw : input real : Nuclear heating in TF coils (MW) ensxpfm : input real : Maximum PF coil stored energy (MJ) t_plant_pulse_plasma_present : input real : Pulse length of cycle (s) c_tf_turn : input real : Current per turn in TF coils (A) tfno : input real : Number of TF coils helpow : output real : Helium heat removal at cryo temperatures (W) This routine calculates the cryogenic heat load. D. Slack memo SCMDG 88-5-1-059, LLNL ITER-88-054, Aug. 1988

Parameters:

Name Type Description Default
i_tf_sup
required
tfcryoarea
required
coldmass
required
p_tf_nuclear_heat_mw
required
ensxpfm
required
t_plant_pulse_plasma_present
required
c_tf_turn
required
n_tf_coils
required
Source code in process/models/power.py
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
def cryo(
    self,
    i_tf_sup,
    tfcryoarea,
    coldmass,
    p_tf_nuclear_heat_mw,
    ensxpfm,
    t_plant_pulse_plasma_present,
    c_tf_turn,
    n_tf_coils,
):
    """Calculates cryogenic loads

    itfsup : input integer : Switch denoting whether TF coils are
    superconducting
    tfcryoarea : input real : Surface area of toroidal shells covering TF coils (m2)
    coldmass : input real : Mass of cold (cryogenic) components (kg),
    including TF coils, PF coils, cryostat, and
    intercoil structure
    p_tf_nuclear_heat_mw : input real : Nuclear heating in TF coils (MW)
    ensxpfm : input real : Maximum PF coil stored energy (MJ)
    t_plant_pulse_plasma_present : input real : Pulse length of cycle (s)
    c_tf_turn : input real : Current per turn in TF coils (A)
    tfno : input real : Number of TF coils
    helpow : output real : Helium heat removal at cryo temperatures (W)
    This routine calculates the cryogenic heat load.
    D. Slack memo SCMDG 88-5-1-059, LLNL ITER-88-054, Aug. 1988

    Parameters
    ----------
    i_tf_sup :

    tfcryoarea :

    coldmass :

    p_tf_nuclear_heat_mw :

    ensxpfm :

    t_plant_pulse_plasma_present :

    c_tf_turn :

    n_tf_coils :

    """
    power_variables.qss = 4.3e-4 * coldmass
    if i_tf_sup == 1:
        power_variables.qss = power_variables.qss + 2.0e0 * tfcryoarea

    #  Nuclear heating of TF coils (W) (zero if resistive)
    if fwbs_variables.inuclear == 0 and i_tf_sup == 1:
        fwbs_variables.qnuc = 1.0e6 * p_tf_nuclear_heat_mw
    # Issue #511: if fwbs_variables.inuclear = 1 : fwbs_variables.qnuc is input.

    #  AC losses
    power_variables.qac = 1.0e3 * ensxpfm / t_plant_pulse_plasma_present

    #  Current leads
    if i_tf_sup == 1:
        power_variables.qcl = 13.6e-3 * n_tf_coils * c_tf_turn
    else:
        power_variables.qcl = 0.0e0

    #  45% extra miscellaneous, piping and reserves
    power_variables.qmisc = 0.45e0 * (
        power_variables.qss
        + fwbs_variables.qnuc
        + power_variables.qac
        + power_variables.qcl
    )
    return max(
        0.0e0,
        power_variables.qmisc
        + power_variables.qss
        + fwbs_variables.qnuc
        + power_variables.qac
        + power_variables.qcl,
    )

output_cryogenics()

Outputs cryogenic system heat loads and related parameters to the output file.

This method prints the breakdown of cryogenic heat loads, including conduction/radiation, nuclear heating, AC losses, resistive losses in current leads, miscellaneous allowances, and total heat removal at cryogenic temperatures. It also outputs the temperatures and efficiencies of the cryogenic systems, as well as the electric power required for the cryogenic plant.

Source code in process/models/power.py
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
def output_cryogenics(self):
    """Outputs cryogenic system heat loads and related parameters to the output file.

    This method prints the breakdown of cryogenic heat loads, including conduction/radiation,
    nuclear heating, AC losses, resistive losses in current leads, miscellaneous allowances,
    and total heat removal at cryogenic temperatures. It also outputs the temperatures and
    efficiencies of the cryogenic systems, as well as the electric power required for the
    cryogenic plant.
    """

    po.oheadr(self.outfile, "Cryogenics")
    po.ovarre(
        self.outfile,
        "Conduction and radiation heat loads on cryogenic components (MW)",
        "(qss/1.0d6)",
        power_variables.qss / 1.0e6,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Nuclear heating of cryogenic components (MW)",
        "(qnuc/1.0d6)",
        fwbs_variables.qnuc / 1.0e6,
        "OP ",
    )
    if fwbs_variables.inuclear == 1:
        po.ocmmnt(
            self.outfile, "Nuclear heating of cryogenic components is a user input."
        )
    po.ovarre(
        self.outfile,
        "AC losses in cryogenic components (MW)",
        "(qac/1.0d6)",
        power_variables.qac / 1.0e6,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Resistive losses in current leads (MW)",
        "(qcl/1.0d6)",
        power_variables.qcl / 1.0e6,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "45% allowance for heat loads in transfer lines, storage tanks etc (MW)",
        "(qmisc/1.0d6)",
        power_variables.qmisc / 1.0e6,
        "OP ",
    )

    po.ovarre(
        self.outfile,
        "Sum = Total heat removal at cryogenic temperatures (temp_tf_cryo & temp_cp_coolant_inlet) (MW)",
        "(helpow + helpow_cryal/1.0d6)",
        (heat_transport_variables.helpow + heat_transport_variables.helpow_cryal)
        * 1.0e-6,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Temperature of cryogenic superconducting components (K)",
        "(temp_tf_cryo)",
        tfcoil_variables.temp_tf_cryo,
    )
    po.ovarre(
        self.outfile,
        "Temperature of cryogenic aluminium components (K)",
        "(temp_cp_coolant_inlet)",
        tfcoil_variables.temp_cp_coolant_inlet,
    )
    po.ovarre(
        self.outfile,
        "Electric power for cryogenic plant (MW)",
        "(p_cryo_plant_electric_mw)",
        heat_transport_variables.p_cryo_plant_electric_mw,
        "OP ",
    )

plant_thermal_efficiency(eta_turbine)

Calculates the thermal efficiency of the power conversion cycle

eta_turbine : input/output real : thermal to electric conversion efficiency This routine calculates the thermal efficiency of the power conversion cycle. This gives the gross power of the plant, i.e. the primary coolant pumping power is not subtracted at this point; however, the pumping of the secondary coolant is accounted for.

If i_thermal_electric_conversion = 0, 1, a set efficiency for the chosen blanket design is used, taken from cycle modelling studies.

If i_thermal_electric_conversion > 1, the outlet temperature from the first wall and breeder zone is used to calculate an efficiency, using a simple relationship between eta_turbine and temp_blkt_coolant_out again obtained from previous studies. C. Harrington, K:Power Plant Physics and Technology PROCESS blanket_model New Power Module Harrington Cycle correlations Cycle correlations.xls

Parameters:

Name Type Description Default
eta_turbine
required
Source code in process/models/power.py
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
def plant_thermal_efficiency(self, eta_turbine):
    """Calculates the thermal efficiency of the power conversion cycle


    eta_turbine : input/output real : thermal to electric conversion efficiency
    This routine calculates the thermal efficiency of the power conversion cycle.
    This gives the gross power of the plant, i.e. the primary coolant pumping
    power is not subtracted at this point; however, the pumping of the
    secondary coolant is accounted for.
    <P>If i_thermal_electric_conversion = 0, 1, a set efficiency for the chosen blanket design is used,
    taken from cycle modelling studies.
    <P>If i_thermal_electric_conversion > 1, the outlet temperature from the first wall
    and breeder zone is used to calculate an efficiency, using a simple relationship
    between eta_turbine and temp_blkt_coolant_out again obtained from previous studies.
    C. Harrington, K:Power Plant Physics and Technology  PROCESS  blanket_model
     New Power Module Harrington  Cycle correlations  Cycle correlations.xls

    Parameters
    ----------
    eta_turbine :

    """
    if fwbs_variables.i_thermal_electric_conversion == 0:
        #  CCFE HCPB Model
        if fwbs_variables.i_blanket_type == 1:
            #  HCPB, efficiency taken from M. Kovari 2016
            # "PROCESS": A systems code for fusion power plants - Part 2: Engineering
            # https://www.sciencedirect.com/science/article/pii/S0920379616300072
            # Feedheat & reheat cycle assumed
            eta_turbine = 0.411e0
        else:
            logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

        #  Etath from reference. Div power to primary
    elif fwbs_variables.i_thermal_electric_conversion == 1:
        #  CCFE HCPB Model
        if fwbs_variables.i_blanket_type == 1:
            #  HCPB, efficiency taken from M. Kovari 2016
            # "PROCESS": A systems code for fusion power plants - Part 2: Engineering
            # https://www.sciencedirect.com/science/article/pii/S0920379616300072
            # Feedheat & reheat cycle assumed
            eta_turbine = 0.411e0 - power_variables.delta_eta
        else:
            logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

        #  User input used, eta_turbine not changed
    elif fwbs_variables.i_thermal_electric_conversion == 2:
        return eta_turbine
        # Do nothing

        #  Steam Rankine cycle to be used
    elif fwbs_variables.i_thermal_electric_conversion == 3:
        #  CCFE HCPB Model
        if fwbs_variables.i_blanket_type == 1:
            #  If coolant is helium, the steam cycle is assumed to be superheated
            #  and a different correlation is used. The turbine inlet temperature
            #  is assumed to be 20 degrees below the primary coolant outlet
            #  temperature, as was stated for steam rankine cycle for Helium in
            #  M. Kovari 2016, "PROCESS": A systems code for fusion power plants
            #  - Part 2: Engineering
            #  https://www.sciencedirect.com/science/article/pii/S0920379616300072

            #  Superheated steam Rankine cycle correlation (C. Harrington)
            #  Range of validity: 657 K < heat_transport_variables.temp_turbine_coolant_in < 915 K
            heat_transport_variables.temp_turbine_coolant_in = (
                fwbs_variables.temp_blkt_coolant_out - 20.0e0
            )
            if (heat_transport_variables.temp_turbine_coolant_in < 657.0e0) or (
                heat_transport_variables.temp_turbine_coolant_in > 915.0e0
            ):
                logger.warning(
                    "Turbine temperature temp_turbine_coolant_in out of range of validity"
                    f"{heat_transport_variables.temp_turbine_coolant_in=}"
                )

            eta_turbine = (
                0.1802e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
                - 0.7823
                - power_variables.delta_eta
            )

        else:
            logger.log(f"{'i_blanket_type does not have a value in range 1-3.'}")

        #  Supercritical CO2 cycle to be used
    elif fwbs_variables.i_thermal_electric_conversion == 4:
        #  The same temperature/efficiency correlation is used regardless of
        #  primary coolant choice.  The turbine inlet temperature is assumed to
        #  be 20 degrees below the primary coolant outlet temperature.
        #  s-CO2 can in theory be used for both helium and water primary coolants
        #  so no differentiation is made, but for water the efficiency will be
        #  very low and the correlation will reflect this.

        #  Supercritical CO2 cycle correlation (C. Harrington)
        #  Range of validity: 408 K < heat_transport_variables.temp_turbine_coolant_in < 1023 K
        heat_transport_variables.temp_turbine_coolant_in = (
            fwbs_variables.temp_blkt_coolant_out - 20.0e0
        )
        if (heat_transport_variables.temp_turbine_coolant_in < 408.0e0) or (
            heat_transport_variables.temp_turbine_coolant_in > 1023.0e0
        ):
            logger.warning(
                "Turbine temperature temp_turbine_coolant_in out of range of validity"
                f"{heat_transport_variables.temp_turbine_coolant_in=}"
            )

        eta_turbine = (
            0.4347e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
            - 2.5043e0
        )

    else:
        logger.log(
            f"{'i_thermal_electric_conversion does not appear to have a value within its range (0-4)'}"
        )
    return eta_turbine

plant_thermal_efficiency_2(etath_liq)

Calculates the thermal efficiency of the power conversion cycle for the liquid metal breeder

Parameters:

Name Type Description Default
etath_liq
required
Source code in process/models/power.py
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
def plant_thermal_efficiency_2(self, etath_liq):
    """Calculates the thermal efficiency of the power conversion cycle
    for the liquid metal breeder

    Parameters
    ----------
    etath_liq :

    """
    if fwbs_variables.secondary_cycle_liq == 2:
        #  User input used, eta_turbine not changed
        return etath_liq

    if fwbs_variables.secondary_cycle_liq == 4:
        #  Supercritical CO2 cycle to be used
        #  Supercritical CO2 cycle correlation (C. Harrington)
        #  Range of validity: 408 K < heat_transport_variables.temp_turbine_coolant_in < 1023 K
        heat_transport_variables.temp_turbine_coolant_in = (
            fwbs_variables.outlet_temp_liq - 20.0e0
        )
        if (heat_transport_variables.temp_turbine_coolant_in < 408.0e0) or (
            heat_transport_variables.temp_turbine_coolant_in > 1023.0e0
        ):
            logger.warning(
                "Turbine temperature temp_turbine_coolant_in out of range of validity"
                f"{heat_transport_variables.temp_turbine_coolant_in=}"
            )

        return (
            0.4347e0 * np.log(heat_transport_variables.temp_turbine_coolant_in)
            - 2.5043e0
        )

    raise ProcessValueError(
        f"secondary_cycle_liq ={fwbs_variables.secondary_cycle_liq} is an invalid option."
    )

tfpwr(output)

TF coil power supply requirements for resistive coils

outfile : input integer : output file unit iprint : input integer : switch for writing to output (1=yes) This routine calculates the power conversion requirements for resistive TF coils, or calls tfpwcall if the TF coils are superconducting. None

Parameters:

Name Type Description Default
output bool
required
Source code in process/models/power.py
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
def tfpwr(self, output: bool):
    """TF coil power supply requirements for resistive coils

    outfile : input integer : output file unit
    iprint : input integer : switch for writing to output (1=yes)
    This routine calculates the power conversion requirements for
    resistive TF coils, or calls <CODE>tfpwcall</CODE> if the TF
    coils are superconducting.
    None

    Parameters
    ----------
    output: bool

    """
    if tfcoil_variables.i_tf_sup != 1:
        # Cross-sectional area of bus
        # tfcoil_variables.c_tf_turn  - current per TFC turn (A)
        # tfcoil_variables.j_tf_bus   - bus current density (A/m2)
        a_tf_bus = tfcoil_variables.c_tf_turn / tfcoil_variables.j_tf_bus

        # Bus resistance [ohm]
        # Bus resistivity (tfcoil_variables.rho_tf_bus)
        # Issue #1253: there was a fudge here to set the bus bar resistivity equal
        # to the TF conductor resistivity. I have removed this.
        tfbusres = (
            tfcoil_variables.rho_tf_bus * tfcoil_variables.len_tf_bus / a_tf_bus
        )

        #  Bus mass (kg)
        tfcoil_variables.m_tf_bus = (
            tfcoil_variables.len_tf_bus * a_tf_bus * constants.den_copper
        )

        #  Total maximum impedance MDK actually just fixed resistance
        res_tf_system_total = (
            tfcoil_variables.n_tf_coils * tfcoil_variables.res_tf_leg
            + (tfcoil_variables.p_cp_resistive / tfcoil_variables.c_tf_total**2)
            + tfbusres
        )

        #  No reactive portion of the voltage is included here - assume long ramp times
        #  MDK This is steady state voltage, not "peak" voltage
        tfcoil_variables.vtfkv = (
            1.0e-3
            * res_tf_system_total
            * tfcoil_variables.c_tf_turn
            / tfcoil_variables.n_tf_coils
        )

        # Resistive powers (MW):
        tfcoil_variables.p_cp_resistive_mw = (
            1.0e-6 * tfcoil_variables.p_cp_resistive
        )  # inboard legs (called centrepost, CP for tart design)
        tfcoil_variables.p_tf_leg_resistive_mw = (
            1.0e-6 * tfcoil_variables.p_tf_leg_resistive
        )  # outboard legs
        tfcoil_variables.p_tf_joints_resistive_mw = (
            1.0e-6 * tfcoil_variables.p_tf_joints_resistive
        )  # Joints
        tfbusmw = (
            1.0e-6 * tfcoil_variables.c_tf_turn**2 * tfbusres
        )  # TF coil bus => Dodgy #

        #  TF coil reactive power
        #  Set reactive power to 0, since ramp up can be long
        #  The TF coil can be ramped up as slowly as you like
        #  (although this will affect the time to recover from a magnet quench).
        #     tfreacmw = 1.0e-6 * 1.0e9 * estotf/(t_plant_pulse_plasma_current_ramp_up + t_plant_pulse_coil_precharge)
        #                                 estotf(=e_tf_magnetic_stored_total_gj/tfcoil_variables.n_tf_coils) has been removed (#199 #847)
        tfreacmw = 0.0e0

        # Total power consumption (MW)
        tfcoil_variables.tfcmw = (
            tfcoil_variables.p_cp_resistive_mw
            + tfcoil_variables.p_tf_leg_resistive_mw
            + tfbusmw
            + tfreacmw
            + tfcoil_variables.p_tf_joints_resistive_mw
        )

        # Total steady state AC power demand (MW)
        heat_transport_variables.p_tf_electric_supplies_mw = (
            tfcoil_variables.tfcmw / heat_transport_variables.etatf
        )

    else:  # Superconducting TF coil option
        self.tfpwcall(output)
        return

    # Output section
    if output == 0:
        return
    # Clarify that these outputs are for resistive coils only
    po.oheadr(self.outfile, "Resistive TF Coil Power Conversion")
    po.ovarre(self.outfile, "Bus resistance (ohm)", "(tfbusres)", tfbusres, "OP ")
    po.ovarre(
        self.outfile,
        "Bus current density (A/m2)",
        "(j_tf_bus)",
        tfcoil_variables.j_tf_bus,
    )
    po.ovarre(
        self.outfile,
        "Bus length - all coils (m)",
        "(len_tf_bus)",
        tfcoil_variables.len_tf_bus,
    )
    po.ovarre(
        self.outfile,
        "Bus mass (kg)",
        "(m_tf_bus)",
        tfcoil_variables.m_tf_bus,
        "OP ",
    )
    # po.ovarre(outfile,'Maximum impedance (ohm)','(ztot)',ztot)
    po.ovarre(
        self.outfile,
        "Total resistance for TF coil set (ohm)",
        "(res_tf_system_total)",
        res_tf_system_total,
        "OP ",
    )
    # po.ovarre(outfile,'Peak voltage per coil (kV)','(vtfkv)',vtfkv)
    po.ovarre(
        self.outfile,
        "Steady-state voltage per coil (kV)",
        "(vtfkv)",
        tfcoil_variables.vtfkv,
        "OP ",
    )
    # po.ovarre(outfile,'Peak power (MW)','(tfcmw..)',tfcmw)
    po.ovarre(
        self.outfile,
        "Total power dissipation in TF coil set (MW)",
        "(tfcmw..)",
        tfcoil_variables.tfcmw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Power dissipation in TF coil set: inboard legs (MW)",
        "(p_cp_resistive_mw)",
        tfcoil_variables.p_cp_resistive_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Power dissipation in TF coil set: outboard legs (MW)",
        "(p_tf_leg_resistive_mw)",
        tfcoil_variables.p_tf_leg_resistive_mw,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Power dissipation in TF coil set: buses",
        "(tfbusmw)",
        tfbusmw,
        "OP ",
    )
    if tfcoil_variables.i_cp_joints != 0:
        po.ovarre(
            self.outfile,
            "Power dissipation in TF coil set: joints",
            "(p_tf_joints_resistive_mw)",
            tfcoil_variables.p_tf_joints_resistive_mw,
            "OP ",
        )

tfpwcall(output)

Calls the TF coil power conversion routine for superconducting coils

outfile : input integer : output file unit iprint : input integer : switch for writing to output (1=yes) This routine calls routine tfcpwr to calculate the power conversion requirements for superconducting TF coils. None

Parameters:

Name Type Description Default
output bool
required
Source code in process/models/power.py
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
def tfpwcall(self, output: bool):
    """Calls the TF coil power conversion routine for
    superconducting coils


    outfile : input integer : output file unit
    iprint : input integer : switch for writing to output (1=yes)
    This routine calls routine <CODE>tfcpwr</CODE> to calculate
    the power conversion requirements for superconducting TF coils.
    None

    Parameters
    ----------
    output: bool

    """
    ettfmj = (
        tfcoil_variables.e_tf_magnetic_stored_total_gj
        / tfcoil_variables.n_tf_coils
        * 1.0e3
    )

    #  TF coil current (kA)

    itfka = 1.0e-3 * tfcoil_variables.c_tf_turn

    (
        tfcoil_variables.tfckw,
        tfcoil_variables.len_tf_bus,
        tfcoil_variables.drarea,
        buildings_variables.tfcbv,
        heat_transport_variables.p_tf_electric_supplies_mw,
    ) = self.tfcpwr(
        output,
        itfka,
        physics_variables.rmajor,
        tfcoil_variables.n_tf_coils,
        tfcoil_variables.v_tf_coil_dump_quench_kv,
        ettfmj,
        tfcoil_variables.res_tf_leg,
    )

tfcpwr(output, itfka, rmajor, ntfc, v_tf_coil_dump_quench_kv, ettfmj, rptfc)

Calculates the TF coil power conversion system parameters for superconducting coils

This routine calculates the TF power conversion systemp arameters: floor space, power supplies, bussing, coil protection equipment, and the associated controls and instrumentation.

Parameters:

Name Type Description Default
itfka
required
rmajor
required
ntfc
required
v_tf_coil_dump_quench_kv
required
ettfmj
required
rptfc
required
Source code in process/models/power.py
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
def tfcpwr(
    self, output: bool, itfka, rmajor, ntfc, v_tf_coil_dump_quench_kv, ettfmj, rptfc
):
    """Calculates the TF coil power conversion system parameters
    for superconducting coils

    This routine calculates the TF power conversion systemp arameters:
    floor space, power supplies, bussing,
    coil protection equipment, and the associated controls
    and instrumentation.

    Parameters
    ----------
    itfka :

    rmajor :

    ntfc :

    v_tf_coil_dump_quench_kv :

    ettfmj :

    rptfc :

    """

    ncpbkr = 1.0e0  # number of TF coils per circuit breaker
    djmka = 0.125e0  # design current density of TF bus, kA/cm2
    rtfps = 1.05e0  # rating factor for TF coil power supplies
    fspc1 = 0.15e0  # floor space coefficient for power supplies
    fspc2 = 0.8e0  # floor space coefficient for circuit breakers
    fspc3 = 0.4e0  # floor space coefficient for load centres

    if rptfc == 0.0e0:
        tchghr = 4.0e0  # charge time of the coils, hours
        nsptfc = 1.0e0  # superconducting (1.0 = superconducting, 0.0 = resistive)
    else:
        tchghr = 0.16667e0  # charge time of the coils, hours
        nsptfc = 0.0e0  # resistive (1.0 = superconducting, 0.0 = resistive)

    #  Total steady state TF coil AC power demand (summed later)
    p_tf_electric_supplies_mw = 0.0e0

    #  Stored energy of all TF coils, MJ
    ettfc = ntfc * ettfmj

    #  Inductance of all TF coils, Henries
    ltfth = 2.0e0 * ettfc / itfka**2

    #  Number of circuit breakers
    ntfbkr = ntfc / ncpbkr

    #  Inductance per TF coil, Henries
    lptfcs = ltfth / ntfc

    #  Aluminium bus section area, sq cm
    albusa = itfka / djmka

    #  Total TF system bus length, m
    len_tf_bus = (
        8.0e0 * np.pi * rmajor
        + (1.0e0 + ntfbkr) * (12.0e0 * rmajor + 80.0e0)
        + 0.2e0 * itfka * np.sqrt(ntfc * rptfc * 1000.0e0)
    )

    #  Aluminium bus weight, tonnes
    albuswt = 2.7e0 * albusa * len_tf_bus / 1.0e4

    #  Total resistance of TF bus, ohms
    # rtfbus = 2.62e-4 * len_tf_bus / albusa
    rtfbus = tfcoil_variables.rho_tf_bus * len_tf_bus / (albusa / 10000)

    #  Total voltage drop across TF bus, volts
    vtfbus = 1000.0e0 * itfka * rtfbus

    #  Total resistance of the TF coils, ohms
    rcoils = ntfc * rptfc

    #  Total impedance, ohms
    ztotal = rtfbus + rcoils + ltfth / (3600.0e0 * tchghr)

    #  Charging voltage for the TF coils, volts
    tfcv = 1000.0e0 * itfka * ztotal

    #  Number of TF power modules
    ntfpm = (itfka * (1.0e0 + nsptfc)) / 5.0e0

    #  TF coil power module voltage, volts
    tfpmv = rtfps * tfcv / (1.0e0 + nsptfc)

    #  TF coil power supply voltage, volts
    tfpsv = rtfps * tfcv

    #  Power supply current, kA
    tfpska = rtfps * itfka

    #  TF power module current, kA
    tfpmka = rtfps * itfka / (ntfpm / (1.0e0 + nsptfc))

    #  TF power module power, kW
    tfpmkw = tfpmv * tfpmka

    #  Available DC power for charging the TF coils, kW
    tfckw = tfpmkw * ntfpm

    #  Peak AC power needed to charge coils, kW
    tfackw = tfckw / 0.9e0

    #  Resistance of dump resistor, ohms
    r1dump = nsptfc * v_tf_coil_dump_quench_kv * ncpbkr / itfka

    #  Time constant, s
    ttfsec = lptfcs * ncpbkr / (r1dump * nsptfc + rptfc * (1.0e0 - nsptfc))

    #  Number of dump resistors
    ndumpr = ntfbkr * 4.0e0

    #  Peak power to a dump resistor during quench, MW
    r1ppmw = nsptfc * r1dump * (itfka / 2.0e0) ** 2

    #  Energy to dump resistor during quench, MJ
    r1emj = nsptfc * ettfc / (ndumpr + 0.0001e0)

    #  Total TF coil peak resistive power demand, MVA
    rpower = (ntfc * rptfc + rtfbus) * itfka**2

    #  Total TF coil peak inductive power demand, MVA
    xpower = ltfth / (3600.0e0 * tchghr) * itfka**2

    #  Building space:
    #  Power modules floor space, m2
    part1 = fspc1 * ntfpm * tfpmkw**0.667e0

    #  Circuit breakers floor space, m2
    part2 = fspc2 * ntfbkr * (v_tf_coil_dump_quench_kv * itfka) ** 0.667e0

    #  Load centres floor space, m2
    part3 = (
        fspc3 * (tfackw / (2.4e0 * nsptfc + 13.8e0 * (1.0e0 - nsptfc))) ** 0.667e0
    )

    #  Power conversion building floor area, m2
    tfcfsp = part1 + part2 + part3

    #  Dump resistor floor area, m2
    drarea = 0.5e0 * ndumpr * (1.0e0 + r1emj) ** 0.667e0

    #  Total TF coil power conversion building volume, m3
    tfcbv = 6.0e0 * tfcfsp

    #  TF coil AC inductive power demand, MW
    xpwrmw = xpower / 0.9e0

    #  Total steady state AC power demand, MW
    p_tf_electric_supplies_mw = (
        p_tf_electric_supplies_mw + rpower / heat_transport_variables.etatf
    )
    #  Total TF coil power conversion building floor area, m2

    # tftsp = tfcfsp
    #  Total TF coil power conversion building volume, m3

    # tftbv = tfcbv

    #  Output section
    if output:
        po.oheadr(self.outfile, "Superconducting TF Coil Power Conversion")
        po.ovarre(self.outfile, "TF coil current (kA)", "(itfka)", itfka, "OP ")
        po.ovarre(self.outfile, "Number of TF coils", "(ntfc)", ntfc)
        po.ovarre(
            self.outfile,
            "Voltage across a TF coil during quench (kV)",
            "(v_tf_coil_dump_quench_kv)",
            v_tf_coil_dump_quench_kv,
            "OP ",
        )
        po.ovarre(self.outfile, "TF coil charge time (hours)", "(tchghr)", tchghr)
        po.ovarre(
            self.outfile,
            "Total inductance of TF coils (H)",
            "(ltfth)",
            ltfth,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total resistance of TF coils (ohm)",
            "(rcoils)",
            rcoils,
            "OP ",
        )
        # MDK Remove this as it leads to confusion between (a) total inductance/n_tf_coils, or (b)
        #     self-inductance of one single coil
        # po.ovarre(outfile,'Inductance per TF coil (H)','(lptfcs)',lptfcs, 'OP ')
        po.ovarre(self.outfile, "TF coil charging voltage (V)", "(tfcv)", tfcv)
        po.ovarre(self.outfile, "Number of DC circuit breakers", "(ntfbkr)", ntfbkr)
        po.ovarre(self.outfile, "Number of dump resistors", "(ndumpr)", ndumpr)
        po.ovarre(
            self.outfile,
            "Resistance per dump resistor (ohm)",
            "(r1dump)",
            r1dump,
            "OP ",
        )
        po.ovarre(
            self.outfile, "Dump resistor peak power (MW)", "(r1ppmw)", r1ppmw, "OP "
        )
        po.ovarre(
            self.outfile,
            "Energy supplied per dump resistor (MJ)",
            "(r1emj)",
            r1emj,
            "OP ",
        )
        po.ovarre(
            self.outfile, "TF coil L/R time constant (s)", "(ttfsec)", ttfsec, "OP "
        )

        po.ovarre(self.outfile, "Power supply voltage (V)", "(tfpsv)", tfpsv, "OP ")
        po.ovarre(
            self.outfile, "Power supply current (kA)", "(tfpska)", tfpska, "OP "
        )
        po.ovarre(
            self.outfile, "DC power supply rating (kW)", "(tfckw)", tfckw, "OP "
        )
        po.ovarre(
            self.outfile, "AC power for charging (kW)", "(tfackw)", tfackw, "OP "
        )
        po.ovarre(
            self.outfile, "TF coil resistive power (MW)", "(rpower)", rpower, "OP "
        )

        po.ovarre(
            self.outfile, "TF coil inductive power (MVA)", "(xpower)", xpower, "OP "
        )
        po.ovarre(
            self.outfile, "Aluminium bus current density (kA/cm2)", "(djmka)", djmka
        )
        po.ovarre(
            self.outfile,
            "Aluminium bus cross-sectional area (cm2)",
            "(albusa)",
            albusa,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total length of TF coil bussing (m)",
            "(len_tf_bus)",
            len_tf_bus,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Aluminium bus weight (tonnes)",
            "(albuswt)",
            albuswt,
            "OP ",
        )

        po.ovarre(
            self.outfile,
            "Total TF coil bus resistance (ohm)",
            "(rtfbus)",
            rtfbus,
            "OP ",
        )
        po.ovarre(
            self.outfile, "TF coil bus voltage drop (V)", "(vtfbus)", vtfbus, "OP "
        )
        po.ovarre(
            self.outfile, "Dump resistor floor area (m2)", "(drarea)", drarea, "OP "
        )
        po.ovarre(
            self.outfile,
            "TF coil power conversion floor space (m2)",
            "(tfcfsp)",
            tfcfsp,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "TF coil power conv. building volume (m3)",
            "(tfcbv)",
            tfcbv,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "TF coil AC inductive power demand (MW)",
            "(xpwrmw)",
            xpwrmw,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total steady state AC power demand (MW)",
            "(p_tf_electric_supplies_mw)",
            p_tf_electric_supplies_mw,
            "OP ",
        )

    return (tfckw, len_tf_bus, drarea, tfcbv, p_tf_electric_supplies_mw)

power_profiles_over_time(t_precharge, t_current_ramp_up, t_fusion_ramp, t_burn, t_ramp_down, t_between_pulse, p_plant_electric_base_total_mw, p_cryo_plant_electric_mw, p_tritium_plant_electric_mw, vachtmw, p_tf_electric_supplies_mw, p_pf_electric_supplies_mw, p_coolant_pump_elec_total_mw, p_hcd_electric_total_mw, p_fusion_total_mw, p_plant_electric_gross_mw, p_plant_electric_net_mw)

Calculate time-dependent power profiles for different electric systems

Parameters:

Name Type Description Default
t_precharge float

Precharge time (s).

required
t_current_ramp_up float

Current ramp-up time (s).

required
t_fusion_ramp float

Fusion ramp time (s).

required
t_burn float

Burn time (s).

required
t_ramp_down float

Ramp-down time (s).

required
t_between_pulse float

Time between pulses (s).

required
p_plant_electric_base_total_mw float

Plant base electric load (MW).

required
p_cryo_plant_electric_mw float

Cryogenic plant electric load (MW).

required
p_tritium_plant_electric_mw float

Tritium plant electric load (MW).

required
vachtmw float

Vacuum pumps electric load (MW).

required
p_tf_electric_supplies_mw float

TF coil electric supplies (MW).

required
p_pf_electric_supplies_mw float

PF coil electric supplies (MW).

required
p_coolant_pump_elec_total_mw float

Total coolant pump electric load (MW).

required
p_hcd_electric_total_mw float

HCD electric total (MW).

required
p_fusion_total_mw float

Fusion power (MW).

required
p_plant_electric_gross_mw float

Gross electric power produced (MW).

required
p_plant_electric_net_mw float

Net electric power produced (MW).

required

Returns:

Type Description
float

Total net electric energy produced over the pulse (MJ).

Notes
  • Assumes step-function changes in power at each phase transition.
  • Negative values indicate power consumption (loads).
Source code in process/models/power.py
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
def power_profiles_over_time(
    self,
    t_precharge: float,
    t_current_ramp_up: float,
    t_fusion_ramp: float,
    t_burn: float,
    t_ramp_down: float,
    t_between_pulse: float,
    p_plant_electric_base_total_mw: float,
    p_cryo_plant_electric_mw: float,
    p_tritium_plant_electric_mw: float,
    vachtmw: float,
    p_tf_electric_supplies_mw: float,
    p_pf_electric_supplies_mw: float,
    p_coolant_pump_elec_total_mw: float,
    p_hcd_electric_total_mw: float,
    p_fusion_total_mw: float,
    p_plant_electric_gross_mw: float,
    p_plant_electric_net_mw: float,
) -> float:
    """Calculate time-dependent power profiles for different electric systems

    Parameters
    ----------
    t_precharge : float
        Precharge time (s).
    t_current_ramp_up : float
        Current ramp-up time (s).
    t_fusion_ramp : float
        Fusion ramp time (s).
    t_burn : float
        Burn time (s).
    t_ramp_down : float
        Ramp-down time (s).
    t_between_pulse : float
        Time between pulses (s).
    p_plant_electric_base_total_mw : float
        Plant base electric load (MW).
    p_cryo_plant_electric_mw : float
        Cryogenic plant electric load (MW).
    p_tritium_plant_electric_mw : float
        Tritium plant electric load (MW).
    vachtmw : float
        Vacuum pumps electric load (MW).
    p_tf_electric_supplies_mw : float
        TF coil electric supplies (MW).
    p_pf_electric_supplies_mw : float
        PF coil electric supplies (MW).
    p_coolant_pump_elec_total_mw : float
        Total coolant pump electric load (MW).
    p_hcd_electric_total_mw : float
        HCD electric total (MW).
    p_fusion_total_mw : float
        Fusion power (MW).
    p_plant_electric_gross_mw : float
        Gross electric power produced (MW).
    p_plant_electric_net_mw : float
        Net electric power produced (MW).

    Returns
    -------
    float
        Total net electric energy produced over the pulse (MJ).

    Notes
    -----
    - Assumes step-function changes in power at each phase transition.
    - Negative values indicate power consumption (loads).
    """

    t_steps = np.cumsum([
        0,
        t_precharge,
        t_current_ramp_up,
        t_fusion_ramp,
        t_burn,
        t_ramp_down,
        t_between_pulse,
    ])

    # Number of time steps
    n_steps = len(t_steps)

    # Initialize arrays for each power profile
    p_fusion_total_profile_mw = np.zeros(n_steps)
    p_plant_electric_base_total_profile_mw = np.zeros(n_steps)
    p_cryo_plant_electric_profile_mw = np.zeros(n_steps)
    p_tritium_plant_electric_profile_mw = np.zeros(n_steps)
    vachtmw_profile_mw = np.zeros(n_steps)
    p_tf_electric_supplies_profile_mw = np.zeros(n_steps)
    p_pf_electric_supplies_profile_mw = np.zeros(n_steps)
    p_coolant_pump_elec_total_profile_mw = np.zeros(n_steps)
    p_hcd_electric_total_profile_mw = np.zeros(n_steps)
    p_plant_electric_gross_profile_mw = np.zeros(n_steps)
    p_plant_electric_net_profile_mw = np.zeros(n_steps)

    # Fusion power: zero until ramp-up, then during burn
    p_fusion_total_profile_mw[:2] = 0
    p_fusion_total_profile_mw[2:5] = p_fusion_total_mw
    p_fusion_total_profile_mw[5:] = 0

    # Plant base load: constant negative load throughout
    p_plant_electric_base_total_profile_mw[:] = -p_plant_electric_base_total_mw

    # Cryo plant: constant negative load throughout
    p_cryo_plant_electric_profile_mw[:] = -p_cryo_plant_electric_mw

    # Tritium plant: constant negative load throughout
    p_tritium_plant_electric_profile_mw[:] = -p_tritium_plant_electric_mw

    # Vacuum pumps: constant negative load throughout
    vachtmw_profile_mw[:] = -vachtmw

    # TF coil supplies: assume coil is always charged, so constant negative load
    p_tf_electric_supplies_profile_mw[:] = -p_tf_electric_supplies_mw

    # PF coil supplies: zero for first step, then negative during ramp-up and burn, then zero
    p_pf_electric_supplies_profile_mw[0] = 0
    p_pf_electric_supplies_profile_mw[1:5] = -p_pf_electric_supplies_mw
    p_pf_electric_supplies_profile_mw[5:] = 0

    # Coolant pump elec total: zero for first two steps, then negative during ramp-up and burn, then zero
    p_coolant_pump_elec_total_profile_mw[:2] = 0
    p_coolant_pump_elec_total_profile_mw[2:5] = -p_coolant_pump_elec_total_mw
    p_coolant_pump_elec_total_profile_mw[5:] = 0

    # HCD electric total: zero for first two steps, then negative during ramp-up and burn, then zero
    p_hcd_electric_total_profile_mw[:2] = 0
    p_hcd_electric_total_profile_mw[2:5] = -p_hcd_electric_total_mw
    p_hcd_electric_total_profile_mw[5:] = 0

    # Gross electric power: zero for first two steps, then positive during burn, then zero
    p_plant_electric_gross_profile_mw[:2] = 0
    p_plant_electric_gross_profile_mw[2:5] = p_plant_electric_gross_mw
    p_plant_electric_gross_profile_mw[5:] = 0

    # Net electric power: calculated by subtracting all loads from gross electric power
    p_plant_electric_net_profile_mw = (
        p_plant_electric_gross_profile_mw
        + p_plant_electric_base_total_profile_mw
        + p_cryo_plant_electric_profile_mw
        + p_tritium_plant_electric_profile_mw
        + vachtmw_profile_mw
        + p_tf_electric_supplies_profile_mw
        + p_pf_electric_supplies_profile_mw
        + p_coolant_pump_elec_total_profile_mw
        + p_hcd_electric_total_profile_mw
    )

    if p_plant_electric_net_profile_mw[3] != p_plant_electric_net_mw:
        logger.error(
            "Calculated net electric power during burn does not match input value."
            f"Calculated: {p_plant_electric_net_profile_mw[3]}, Input: {p_plant_electric_net_mw}"
        )

    # Integrate net electric power over the pulse to get total energy produced (MJ)
    # Assume t_steps in seconds, power in MW, so energy in MJ
    energy_made_mj = sp.integrate.trapezoid(p_plant_electric_net_profile_mw, t_steps)
    energy_made_kwh = energy_made_mj / 3.6

    return (
        energy_made_kwh,
        energy_made_mj,
        p_plant_electric_base_total_profile_mw,
        p_plant_electric_gross_profile_mw,
        p_plant_electric_net_profile_mw,
        p_hcd_electric_total_profile_mw,
        p_coolant_pump_elec_total_profile_mw,
        p_tf_electric_supplies_profile_mw,
        p_pf_electric_supplies_profile_mw,
        vachtmw_profile_mw,
        p_tritium_plant_electric_profile_mw,
        p_cryo_plant_electric_profile_mw,
        p_fusion_total_profile_mw,
    )

output_power_profiles_over_time()

Source code in process/models/power.py
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
def output_power_profiles_over_time(
    self,
):
    for i, val in enumerate(power_variables.p_plant_electric_base_total_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric base load at time point {i}",
            f"(p_plant_electric_base_total_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_plant_electric_gross_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric gross at time point {i}",
            f"(p_plant_electric_gross_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_plant_electric_net_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric net at time point {i}",
            f"(p_plant_electric_net_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_hcd_electric_total_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric HCD at time point {i}",
            f"(p_hcd_electric_total_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_coolant_pump_elec_total_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric coolant pump at time point {i}",
            f"(p_coolant_pump_elec_total_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_tf_electric_supplies_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric TF supplies at time point {i}",
            f"(p_tf_electric_supplies_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_pf_electric_supplies_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric PF supplies at time point {i}",
            f"(p_pf_electric_supplies_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.vachtmw_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric vacuum pump power at time point {i}",
            f"(vachtmw_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_tritium_plant_electric_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric tritium plant power at time point {i}",
            f"(p_tritium_plant_electric_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_cryo_plant_electric_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric cryo plant power at time point {i}",
            f"(p_cryo_plant_electric_profile_mw{i})",
            val,
        )
    for i, val in enumerate(power_variables.p_fusion_total_profile_mw):
        po.ovarre(
            self.mfile,
            f"Plant total electric fusion plant power at time point {i}",
            f"(p_fusion_total_profile_mw{i})",
            val,
        )