Skip to content

superconducting

SUPERCONDUCTING_TF_TYPES = {1: 'Nb3Sn ITER', 2: 'Bi-2212', 3: 'NbTi', 4: 'Nb3Sn user', 5: 'Nb3Sn WST', 6: 'REBCO Croco', 7: 'NbTi Ginzburg-Landau', 8: 'REBCO Ginzburg-Landau', 9: 'REBCO Hazelton-Zhai'} module-attribute

SuperconductingTFCoil

Bases: TFCoil

Source code in process/models/tfcoil/superconducting.py
  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
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
class SuperconductingTFCoil(TFCoil):
    def __init__(self):
        self.outfile = constants.NOUT

    def run(self, output: bool):
        """Routine to call the superconductor module for the TF coils

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

        """
        self.iprint = 0

        # Set up TF values share by all coil types
        self.run_base_tf()

        self.sc_tf_internal_geom(
            tfcoil_variables.i_tf_wp_geom,
            tfcoil_variables.i_tf_case_geom,
            tfcoil_variables.i_tf_turns_integer,
        )

        tfcoil_variables.ind_tf_coil = self.tf_coil_self_inductance(
            dr_tf_inboard=build_variables.dr_tf_inboard,
            r_tf_arc=tfcoil_variables.r_tf_arc,
            z_tf_arc=tfcoil_variables.z_tf_arc,
            itart=physics_variables.itart,
            i_tf_shape=tfcoil_variables.i_tf_shape,
            z_tf_inside_half=build_variables.z_tf_inside_half,
            dr_tf_outboard=build_variables.dr_tf_outboard,
            r_tf_outboard_mid=build_variables.r_tf_outboard_mid,
            r_tf_inboard_mid=build_variables.r_tf_inboard_mid,
        )

        (
            superconducting_tf_coil_variables.e_tf_magnetic_stored_total,
            tfcoil_variables.e_tf_magnetic_stored_total_gj,
            tfcoil_variables.e_tf_coil_magnetic_stored,
        ) = self.tf_stored_magnetic_energy(
            ind_tf_coil=tfcoil_variables.ind_tf_coil,
            c_tf_total=tfcoil_variables.c_tf_total,
            n_tf_coils=tfcoil_variables.n_tf_coils,
        )

        (
            tfcoil_variables.cforce,
            tfcoil_variables.vforce,
            tfcoil_variables.vforce_outboard,
            superconducting_tf_coil_variables.vforce_inboard_tot,
            tfcoil_variables.f_vforce_inboard,
        ) = self.tf_field_and_force(
            i_tf_sup=tfcoil_variables.i_tf_sup,
            r_tf_wp_inboard_outer=superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
            r_tf_wp_inboard_inner=superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
            r_tf_outboard_in=superconducting_tf_coil_variables.r_tf_outboard_in,
            dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
            dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
            b_tf_inboard_peak_symmetric=tfcoil_variables.b_tf_inboard_peak_symmetric,
            c_tf_total=tfcoil_variables.c_tf_total,
            n_tf_coils=tfcoil_variables.n_tf_coils,
            dr_tf_plasma_case=tfcoil_variables.dr_tf_plasma_case,
            rmajor=physics_variables.rmajor,
            b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
            r_cp_top=build_variables.r_cp_top,
            itart=physics_variables.itart,
            i_cp_joints=tfcoil_variables.i_cp_joints,
            f_vforce_inboard=tfcoil_variables.f_vforce_inboard,
        )

        # Calculate TF coil areas and masses
        self.generic_tf_coil_area_and_masses()
        self.superconducting_tf_coil_areas_and_masses()

        # Do stress calculations (writes the stress output)
        if output:
            tfcoil_variables.n_rad_per_layer = 500

        try:
            (
                sig_tf_r_max,
                sig_tf_t_max,
                sig_tf_z_max,
                sig_tf_vmises_max,
                s_shear_tf_peak,
                deflect,
                eyoung_axial,
                eyoung_trans,
                eyoung_wp_axial,
                eyoung_wp_trans,
                poisson_wp_trans,
                radial_array,
                s_shear_cea_tf_cond,
                poisson_wp_axial,
                sig_tf_r,
                sig_tf_smeared_r,
                sig_tf_smeared_t,
                sig_tf_smeared_z,
                sig_tf_t,
                s_shear_tf,
                sig_tf_vmises,
                sig_tf_z,
                str_tf_r,
                str_tf_t,
                str_tf_z,
                n_radial_array,
                n_tf_bucking,
                tfcoil_variables.sig_tf_wp,
                sig_tf_case,
                sig_tf_cs_bucked,
                str_wp,
                casestr,
                insstrain,
                sig_tf_wp_av_z,
            ) = self.stresscl(
                int(tfcoil_variables.n_tf_stress_layers),
                int(tfcoil_variables.n_rad_per_layer),
                int(tfcoil_variables.n_tf_wp_stress_layers),
                int(tfcoil_variables.i_tf_bucking),
                float(build_variables.r_tf_inboard_in),
                build_variables.dr_bore,
                build_variables.z_tf_inside_half,
                pfcoil_variables.f_z_cs_tf_internal,
                build_variables.dr_cs,
                build_variables.i_tf_inside_cs,
                build_variables.dr_tf_inboard,
                build_variables.dr_cs_tf_gap,
                pfcoil_variables.i_pf_conductor,
                pfcoil_variables.j_cs_flat_top_end,
                pfcoil_variables.j_cs_pulse_start,
                pfcoil_variables.c_pf_coil_turn_peak_input,
                pfcoil_variables.n_pf_coils_in_group,
                pfcoil_variables.f_dr_dz_cs_turn,
                pfcoil_variables.radius_cs_turn_corners,
                pfcoil_variables.f_a_cs_turn_steel,
                tfcoil_variables.eyoung_steel,
                tfcoil_variables.poisson_steel,
                tfcoil_variables.eyoung_cond_axial,
                tfcoil_variables.poisson_cond_axial,
                tfcoil_variables.eyoung_cond_trans,
                tfcoil_variables.poisson_cond_trans,
                tfcoil_variables.eyoung_ins,
                tfcoil_variables.poisson_ins,
                tfcoil_variables.dx_tf_turn_insulation,
                tfcoil_variables.eyoung_copper,
                tfcoil_variables.poisson_copper,
                tfcoil_variables.i_tf_sup,
                tfcoil_variables.eyoung_res_tf_buck,
                superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
                superconducting_tf_coil_variables.tan_theta_coil,
                superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half,
                superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
                superconducting_tf_coil_variables.a_tf_coil_inboard_steel,
                superconducting_tf_coil_variables.a_tf_plasma_case,
                superconducting_tf_coil_variables.a_tf_coil_nose_case,
                tfcoil_variables.dx_tf_wp_insertion_gap,
                tfcoil_variables.dx_tf_wp_insulation,
                tfcoil_variables.n_tf_coil_turns,
                int(tfcoil_variables.i_tf_turns_integer),
                superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
                superconducting_tf_coil_variables.dr_tf_turn_cable_space,
                tfcoil_variables.dia_tf_turn_coolant_channel,
                tfcoil_variables.f_a_tf_turn_cable_copper,
                tfcoil_variables.dx_tf_turn_steel,
                superconducting_tf_coil_variables.dx_tf_side_case_average,
                superconducting_tf_coil_variables.dx_tf_wp_toroidal_average,
                superconducting_tf_coil_variables.a_tf_coil_inboard_insulation,
                tfcoil_variables.a_tf_wp_steel,
                tfcoil_variables.a_tf_wp_conductor,
                superconducting_tf_coil_variables.a_tf_wp_with_insulation,
                tfcoil_variables.eyoung_al,
                tfcoil_variables.poisson_al,
                tfcoil_variables.fcoolcp,
                tfcoil_variables.n_tf_graded_layers,
                tfcoil_variables.c_tf_total,
                tfcoil_variables.dr_tf_plasma_case,
                tfcoil_variables.i_tf_stress_model,
                superconducting_tf_coil_variables.vforce_inboard_tot,
                tfcoil_variables.i_tf_tresca,
                tfcoil_variables.a_tf_coil_inboard_case,
                tfcoil_variables.vforce,
                tfcoil_variables.a_tf_turn_steel,
            )

            tfcoil_variables.sig_tf_case = (
                tfcoil_variables.sig_tf_case
                if tfcoil_variables.sig_tf_case is None
                else sig_tf_case
            )

            tfcoil_variables.sig_tf_cs_bucked = (
                tfcoil_variables.sig_tf_cs_bucked
                if tfcoil_variables.sig_tf_cs_bucked is None
                else sig_tf_cs_bucked
            )

            tfcoil_variables.str_wp = (
                tfcoil_variables.str_wp if tfcoil_variables.str_wp is None else str_wp
            )

            tfcoil_variables.casestr = (
                tfcoil_variables.casestr if tfcoil_variables.casestr is None else casestr
            )

            tfcoil_variables.insstrain = (
                tfcoil_variables.insstrain
                if tfcoil_variables.insstrain is None
                else insstrain
            )

            if output:
                self.out_stress(
                    sig_tf_r_max,
                    sig_tf_t_max,
                    sig_tf_z_max,
                    sig_tf_vmises_max,
                    s_shear_tf_peak,
                    deflect,
                    eyoung_axial,
                    eyoung_trans,
                    eyoung_wp_axial,
                    eyoung_wp_trans,
                    poisson_wp_trans,
                    radial_array,
                    s_shear_cea_tf_cond,
                    poisson_wp_axial,
                    sig_tf_r,
                    sig_tf_smeared_r,
                    sig_tf_smeared_t,
                    sig_tf_smeared_z,
                    sig_tf_t,
                    s_shear_tf,
                    sig_tf_vmises,
                    sig_tf_z,
                    str_tf_r,
                    str_tf_t,
                    str_tf_z,
                    n_radial_array,
                    n_tf_bucking,
                    sig_tf_wp_av_z,
                )
        except ValueError as e:
            if e.args[1] == 245 and e.args[2] == 0:
                logger.warning(
                    "Invalid stress model (r_tf_inboard = 0), stress constraint switched off"
                )
                tfcoil_variables.sig_tf_case = 0.0e0
                tfcoil_variables.sig_tf_wp = 0.0e0

        self.vv_stress_on_quench()

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

        # Peak inboard toroidal field including ripple
        tfcoil_variables.b_tf_inboard_peak_with_ripple = self.peak_b_tf_inboard_with_ripple(
            n_tf_coils=tfcoil_variables.n_tf_coils,
            dx_tf_wp_primary_toroidal=tfcoil_variables.dx_tf_wp_primary_toroidal,
            dr_tf_wp_no_insulation=superconducting_tf_coil_variables.dr_tf_wp_no_insulation,
            r_tf_wp_inboard_centre=superconducting_tf_coil_variables.r_tf_wp_inboard_centre,
            b_tf_inboard_peak_symmetric=tfcoil_variables.b_tf_inboard_peak_symmetric,
        )
        # ======================================================

        # Cross-sectional area per turn
        a_tf_turn = tfcoil_variables.c_tf_total / (
            tfcoil_variables.j_tf_wp
            * tfcoil_variables.n_tf_coils
            * tfcoil_variables.n_tf_coil_turns
        )

        if tfcoil_variables.i_tf_sc_mat == 6:
            (
                tfcoil_variables.j_tf_wp_critical,
                tfcoil_variables.temp_tf_superconductor_margin,
            ) = self.supercon_croco(
                a_tf_turn,
                tfcoil_variables.b_tf_inboard_peak_with_ripple,
                tfcoil_variables.c_tf_turn,
                tfcoil_variables.tftmp,
                output=output,
            )

            tfcoil_variables.v_tf_coil_dump_quench_kv = (
                self.croco_voltage() / 1.0e3
            )  # TFC Quench voltage in kV

        else:
            (
                tfcoil_variables.j_tf_wp_critical,
                superconducting_tf_coil_variables.j_tf_superconductor_critical,
                superconducting_tf_coil_variables.f_c_tf_turn_operating_critical,
                superconducting_tf_coil_variables.j_tf_superconductor,
                superconducting_tf_coil_variables.j_tf_coil_turn,
                superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
                superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
                superconducting_tf_coil_variables.c_tf_turn_cables_critical,
            ) = self.tf_cable_in_conduit_superconductor_properties(
                a_tf_turn_cable_space=tfcoil_variables.a_tf_turn_cable_space_no_void,
                a_tf_turn=a_tf_turn,
                a_tf_turn_cable_space_effective=superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
                f_a_tf_turn_cable_space_cooling=superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
                b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
                f_a_tf_turn_cable_copper=tfcoil_variables.f_a_tf_turn_cable_copper,
                c_tf_turn=tfcoil_variables.c_tf_turn,
                j_tf_wp=tfcoil_variables.j_tf_wp,
                i_tf_superconductor=tfcoil_variables.i_tf_sc_mat,
                f_strain_scale=tfcoil_variables.fhts,
                temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
                bcritsc=tfcoil_variables.bcritsc,
                tcritsc=tfcoil_variables.tcritsc,
            )

        if tfcoil_variables.i_str_wp == 0:
            strain = tfcoil_variables.str_tf_con_res
        else:
            strain = tfcoil_variables.str_wp

        tfcoil_variables.temp_tf_superconductor_margin = self.calculate_superconductor_temperature_margin(
            i_tf_superconductor=tfcoil_variables.i_tf_sc_mat,
            j_superconductor=superconducting_tf_coil_variables.j_tf_superconductor,
            b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
            strain=strain,
            bc20m=superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
            tc0m=superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
            c0=1.0e10,
            temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
        )

        # Do current density protection calculation
        # Only setup for Nb3Sn at present.
        if tfcoil_variables.i_tf_sc_mat not in {1, 4, 5}:
            logger.warning(
                "Calculating current density protection limit for Nb3Sn TF coil (LTS windings only)"
            )
            # Find the current density limited by the protection limit
            # At present only valid for LTS windings (Nb3Sn properties assumed)
        tfcoil_variables.j_tf_wp_quench_heat_max, v_tf_coil_dump_quench = (
            self.quench_heat_protection_current_density(
                c_tf_turn=tfcoil_variables.c_tf_turn,
                e_tf_coil_magnetic_stored=tfcoil_variables.e_tf_coil_magnetic_stored,
                a_tf_turn_cable_space=tfcoil_variables.a_tf_turn_cable_space_no_void,
                a_tf_turn=a_tf_turn,
                t_tf_quench_dump=tfcoil_variables.t_tf_superconductor_quench,
                f_a_tf_turn_cable_space_conductor=1.0e0
                - superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
                f_a_tf_turn_cable_copper=tfcoil_variables.f_a_tf_turn_cable_copper,
                temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
                temp_tf_conductor_quench_max=tfcoil_variables.temp_tf_conductor_quench_max,
                b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
                cu_rrr=tfcoil_variables.rrr_tf_cu,
                t_tf_quench_detection=tfcoil_variables.t_tf_quench_detection,
                nflutfmax=constraint_variables.nflutfmax,
            )
        )

        tfcoil_variables.v_tf_coil_dump_quench_kv = (
            v_tf_coil_dump_quench / 1.0e3
        )  # TFC Quench voltage in kV

        if output:
            self.outtf()

    def croco_voltage(self) -> float:
        if tfcoil_variables.quench_model == "linear":
            superconducting_tf_coil_variables.time2 = (
                tfcoil_variables.t_tf_superconductor_quench
            )
            croco_voltage = (
                2.0e0
                / superconducting_tf_coil_variables.time2
                * (
                    superconducting_tf_coil_variables.e_tf_magnetic_stored_total
                    / tfcoil_variables.n_tf_coils
                )
                / tfcoil_variables.c_tf_turn
            )
        elif tfcoil_variables.quench_model == "exponential":
            superconducting_tf_coil_variables.tau2 = (
                tfcoil_variables.t_tf_superconductor_quench
            )
            croco_voltage = (
                2.0e0
                / superconducting_tf_coil_variables.tau2
                * (
                    superconducting_tf_coil_variables.e_tf_magnetic_stored_total
                    / tfcoil_variables.n_tf_coils
                )
                / tfcoil_variables.c_tf_turn
            )
        else:
            return 0.0

        return croco_voltage

    def supercon_croco(
        self, a_tf_turn, b_tf_inboard_peak_symmetric, iop, thelium, output: bool
    ):
        """TF superconducting CroCo conductor using REBCO tape

        Parameters
        ----------
        a_tf_turn :

        b_tf_inboard_peak_symmetric :
            Peak field at conductor (T)
        iop :
            Operating current per turn (A)
        thelium :
            He temperature at peak field point (K)
        output:

        """

        j_crit_sc: float = 0.0
        #  Find critical current density in superconducting cable, j_crit_cable
        j_crit_sc, _ = superconductors.jcrit_rebco(thelium, b_tf_inboard_peak_symmetric)
        # tfcoil_variables.a_tf_turn_cable_space_no_void : Cable space - inside area (m2)
        # Set new rebco_variables.dia_croco_strand
        # allowing for scaling of rebco_variables.dia_croco_strand
        rebco_variables.dia_croco_strand = (
            tfcoil_variables.t_conductor / 3.0e0
            - tfcoil_variables.dx_tf_turn_steel * (2.0e0 / 3.0e0)
        )
        superconducting_tf_coil_variables.conductor_acs = (
            9.0e0 / 4.0e0 * np.pi * rebco_variables.dia_croco_strand**2
        )
        tfcoil_variables.a_tf_turn_cable_space_no_void = (
            superconducting_tf_coil_variables.conductor_acs
        )
        superconducting_tf_coil_variables.conductor_area = (
            tfcoil_variables.t_conductor**2
        )  # does this not assume it's a sqaure???

        superconducting_tf_coil_variables.conductor_jacket_area = (
            superconducting_tf_coil_variables.conductor_area
            - superconducting_tf_coil_variables.conductor_acs
        )
        tfcoil_variables.a_tf_turn_steel = (
            superconducting_tf_coil_variables.conductor_jacket_area
        )

        superconducting_tf_coil_variables.conductor_jacket_fraction = (
            superconducting_tf_coil_variables.conductor_jacket_area
            / superconducting_tf_coil_variables.conductor_area
        )
        (
            superconducting_tf_coil_variables.croco_strand_area,
            superconducting_tf_coil_variables.croco_strand_critical_current,
            superconducting_tf_coil_variables.conductor_copper_area,
            superconducting_tf_coil_variables.conductor_copper_fraction,
            superconducting_tf_coil_variables.conductor_copper_bar_area,
            superconducting_tf_coil_variables.conductor_hastelloy_area,
            superconducting_tf_coil_variables.conductor_hastelloy_fraction,
            superconducting_tf_coil_variables.conductor_helium_area,
            superconducting_tf_coil_variables.conductor_helium_fraction,
            superconducting_tf_coil_variables.conductor_solder_area,
            superconducting_tf_coil_variables.conductor_solder_fraction,
            superconducting_tf_coil_variables.conductor_rebco_area,
            superconducting_tf_coil_variables.conductor_rebco_fraction,
            superconducting_tf_coil_variables.conductor_critical_current,
        ) = superconductors.croco(
            j_crit_sc,
            superconducting_tf_coil_variables.conductor_area,
            rebco_variables.dia_croco_strand,
            rebco_variables.dx_croco_strand_copper,
        )

        rebco_variables.coppera_m2 = (
            iop / superconducting_tf_coil_variables.conductor_copper_area
        )

        icrit = superconducting_tf_coil_variables.conductor_critical_current
        j_crit_cable = (
            superconducting_tf_coil_variables.croco_strand_critical_current
            / superconducting_tf_coil_variables.croco_strand_area
        )

        # Critical current density in winding pack
        # a_tf_turn : Area per turn (i.e. entire jacketed conductor with insulation) (m2)
        j_tf_wp_critical = icrit / a_tf_turn
        #  Ratio of operating / critical current
        iooic = iop / icrit
        #  Operating current density
        jwdgop = iop / a_tf_turn
        #  Actual current density in superconductor,
        # which should be equal to jcrit(thelium+tmarg)

        #  when we have found the desired value of tmarg
        jsc = iooic * j_crit_sc

        # Temperature margin
        current_sharing_t = superconductors.current_sharing_rebco(
            b_tf_inboard_peak_symmetric, jsc
        )
        tmarg = current_sharing_t - thelium
        tfcoil_variables.temp_margin = (
            tmarg  # Only used in the availabilty routine - see comment to Issue #526
        )

        if output:  # Output ----------------------------------
            total = (
                superconducting_tf_coil_variables.conductor_copper_area
                + superconducting_tf_coil_variables.conductor_hastelloy_area
                + superconducting_tf_coil_variables.conductor_solder_area
                + superconducting_tf_coil_variables.conductor_jacket_area
                + superconducting_tf_coil_variables.conductor_helium_area
                + superconducting_tf_coil_variables.conductor_rebco_area
            )

            if tfcoil_variables.temp_margin <= 0.0e0:
                logger.error(
                    f"""Negative TFC temperature margin
                temp_margin: {tfcoil_variables.temp_margin}
                b_tf_inboard_peak_symmetric: {b_tf_inboard_peak_symmetric}"""
                )

            po.oheadr(self.outfile, "Superconducting TF Coils")
            po.ovarin(self.outfile, "Superconductor switch", "(isumat)", 6)
            po.ocmmnt(
                self.outfile, "Superconductor used: REBCO HTS tape in CroCo strand"
            )

            po.ovarre(
                self.outfile,
                "Thickness of REBCO layer in tape (m)",
                "(dx_hts_tape_rebco)",
                rebco_variables.dx_hts_tape_rebco,
            )
            po.ovarre(
                self.outfile,
                "Thickness of copper layer in tape (m)",
                "(dx_hts_tape_copper)",
                rebco_variables.dx_hts_tape_copper,
            )
            po.ovarre(
                self.outfile,
                "Thickness of Hastelloy layer in tape (m) ",
                "(dx_hts_tape_hastelloy)",
                rebco_variables.dx_hts_tape_hastelloy,
            )

            po.ovarre(
                self.outfile,
                "Mean width of tape (m)",
                "(dr_hts_tape)",
                rebco_variables.dr_hts_tape,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Diameter of a CroCo strand (m) ",
                "(dia_croco_strand)",
                rebco_variables.dia_croco_strand,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Inner diameter of CroCo copper tube (m) ",
                "(dia_croco_strand_tape_region)",
                rebco_variables.dia_croco_strand_tape_region,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Thickness of of o copper tube (m) ",
                "(dx_croco_strand_copper)",
                rebco_variables.dx_croco_strand_copper,
            )

            po.ovarre(
                self.outfile,
                "Thickness of each HTS tape ",
                "(dx_hts_tape_total)",
                rebco_variables.dx_hts_tape_total,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Thickness of stack of rebco_variables.n_croco_strand_hts_tapes (m) ",
                "(dx_croco_strand_tape_stack)",
                rebco_variables.dx_croco_strand_tape_stack,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Number of rebco_variables.n_croco_strand_hts_tapes in strand",
                "(n_croco_strand_hts_tapes)",
                rebco_variables.n_croco_strand_hts_tapes,
                "OP ",
            )
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "Area of REBCO in strand (m2)",
                "(a_croco_strand_rebco)",
                rebco_variables.a_croco_strand_rebco,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Area of copper in strand (m2)",
                "(a_croco_strand_copper_total)",
                rebco_variables.a_croco_strand_copper_total,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Area of hastelloy substrate in strand (m2) ",
                "(a_croco_strand_hastelloy)",
                rebco_variables.a_croco_strand_hastelloy,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Area of solder in strand (m2)  ",
                "(a_croco_strand_solder)",
                rebco_variables.a_croco_strand_solder,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total: area of CroCo strand (m2)  ",
                "(croco_strand_area)",
                superconducting_tf_coil_variables.croco_strand_area,
                "OP ",
            )
            if (
                abs(
                    superconducting_tf_coil_variables.croco_strand_area
                    - (
                        rebco_variables.a_croco_strand_rebco
                        + rebco_variables.a_croco_strand_copper_total
                        + rebco_variables.a_croco_strand_hastelloy
                        + rebco_variables.a_croco_strand_solder
                    )
                )
                > 1e-6
            ):
                po.ocmmnt(self.outfile, "ERROR: Areas in CroCo strand do not add up")
                logger.error("Areas in CroCo strand do not add up - see OUT.DAT")

            po.oblnkl(self.outfile)
            po.ocmmnt(self.outfile, "Cable information")
            po.ovarin(
                self.outfile,
                "Number of CroCo strands in the cable (fixed) ",
                "",
                6,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total area of cable space (m2)",
                "(a_tf_turn_cable_space_no_void)",
                tfcoil_variables.a_tf_turn_cable_space_no_void,
                "OP ",
            )

            po.oblnkl(self.outfile)
            po.ocmmnt(
                self.outfile,
                "Conductor information (includes jacket, not including insulation)",
            )
            po.ovarre(
                self.outfile,
                "Width of square conductor (cable + steel jacket) (m)",
                "(t_conductor)",
                tfcoil_variables.t_conductor,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Area of conductor (m2)",
                "(area)",
                superconducting_tf_coil_variables.conductor_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "REBCO area of conductor (mm2)",
                "(a_croco_strand_rebco)",
                superconducting_tf_coil_variables.conductor_rebco_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Area of central copper bar (mm2)",
                "(copper_bar_area)",
                superconducting_tf_coil_variables.conductor_copper_bar_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Total copper area of conductor, total (mm2)",
                "(a_croco_strand_copper_total)",
                superconducting_tf_coil_variables.conductor_copper_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Hastelloy area of conductor (mm2)",
                "(a_croco_strand_hastelloy)",
                superconducting_tf_coil_variables.conductor_hastelloy_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Solder area of conductor (mm2)",
                "(a_croco_strand_solder)",
                superconducting_tf_coil_variables.conductor_solder_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Jacket area of conductor (mm2)",
                "(jacket_area)",
                superconducting_tf_coil_variables.conductor_jacket_area,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Helium area of conductor (mm2)",
                "(helium_area)",
                superconducting_tf_coil_variables.conductor_helium_area,
                "OP ",
            )
            if abs(total - superconducting_tf_coil_variables.conductor_area) > 1e-8:
                po.ovarre(
                    self.outfile,
                    "ERROR: conductor areas do not add up:",
                    "(total)",
                    total,
                    "OP ",
                )
                logger.error(f"conductor areas do not add up. total: {total}")

            po.ovarre(
                self.outfile,
                "Critical current of CroCo strand (A)",
                "(croco_strand_critical_current)",
                superconducting_tf_coil_variables.croco_strand_critical_current,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Critical current of conductor (A) ",
                "(conductor_critical_current)",
                superconducting_tf_coil_variables.conductor_critical_current,
                "OP ",
            )

            if global_variables.run_tests == 1:
                po.oblnkl(self.outfile)
                po.ocmmnt(
                    self.outfile,
                    "PROCESS TF Coil peak field fit. Values for t, z and y:",
                )
                po.oblnkl(self.outfile)
                po.ovarre(
                    self.outfile,
                    "Dimensionless winding pack width",
                    "(tf_fit_t)",
                    superconducting_tf_coil_variables.tf_fit_t,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Dimensionless winding pack radial thickness",
                    "(tf_fit_z)",
                    superconducting_tf_coil_variables.tf_fit_z,
                    "OP ",
                )
                po.ovarre(
                    self.outfile,
                    "Ratio of actual peak field to nominal axisymmetric peak field",
                    "(f_b_tf_inboard_peak_ripple_symmetric)",
                    superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric,
                    "OP ",
                )

            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "Helium temperature at peak field (= superconductor temperature) (K)",
                "(thelium)",
                thelium,
            )
            po.ovarre(
                self.outfile,
                "Critical current density in superconductor (A/m2)",
                "(j_crit_sc)",
                j_crit_sc,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Critical current density in cable (A/m2)",
                "(j_crit_cable)",
                j_crit_cable,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Critical current density in winding pack (A/m2)",
                "(j_tf_wp_critical)",
                j_tf_wp_critical,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Actual current density in winding pack (A/m2)",
                "(jwdgop)",
                jwdgop,
                "OP ",
            )

            po.ovarre(
                self.outfile,
                "Minimum allowed temperature margin in superconductor (K)",
                "(temp_tf_superconductor_margin_min)",
                tfcoil_variables.temp_tf_superconductor_margin_min,
            )

            po.ovarre(
                self.outfile,
                "Actual temperature margin in superconductor (K)",
                "(tmarg)",
                tmarg,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Current sharing temperature (K)",
                "(current_sharing_t)",
                current_sharing_t,
                "OP ",
            )
            po.ovarre(self.outfile, "Critical current (A)", "(icrit)", icrit, "OP ")
            po.ovarre(
                self.outfile,
                "Actual current (A)",
                "(c_tf_turn)",
                tfcoil_variables.c_tf_turn,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Actual current / critical current",
                "(iooic)",
                iooic,
                "OP ",
            )

        return j_tf_wp_critical, tmarg

    def tf_cable_in_conduit_superconductor_properties(
        self,
        a_tf_turn_cable_space: float,
        a_tf_turn: float,
        a_tf_turn_cable_space_effective: float,
        f_a_tf_turn_cable_space_cooling: float,
        b_tf_inboard_peak: float,
        f_a_tf_turn_cable_copper: float,
        c_tf_turn: float,
        j_tf_wp: float,
        i_tf_superconductor: int,
        f_strain_scale: float,
        temp_tf_coolant_peak_field: float,
        bcritsc: float,
        tcritsc: float,
    ) -> tuple[float, float, float, float, float, float, float, float]:
        """Calculates the properties of the TF superconducting conductor.

        Parameters
        ----------
        a_tf_turn_cable_space:
            Cable space - inside area (m²).
        a_tf_turn:
            Area per turn (i.e. entire jacketed conductor) (m²).
        a_tf_turn_cable_space_effective:
            Effective cable space area per turn (m²).
        f_a_tf_turn_cable_space_cooling:
            Fraction of cable space used for cooling.
        b_tf_inboard_peak:
            Peak field at conductor (T).
        f_a_tf_turn_cable_copper:
            Fraction of conductor that is copper.
        c_tf_turn:
            Operating current per turn (A).
        j_tf_wp:
            Actual winding pack current density (A/m²).
        i_tf_superconductor:
            Switch for conductor type:
            - 1: ITER Nb3Sn, standard parameters
            - 2: Bi-2212 High Temperature Superconductor
            - 3: NbTi
            - 4: ITER Nb3Sn, user-defined parameters
            - 5: WST Nb3Sn parameterisation
            - 7: Durham Ginzburg-Landau Nb-Ti parameterisation
            - 8: Durham Ginzburg-Landau critical surface model for REBCO
            - 9: Hazelton experimental data + Zhai conceptual model for REBCO
        f_strain_scale:
            Adjustment factor (<= 1) to account for strain, radiation damage, fatigue or AC losses.
        temp_tf_coolant_peak_field:
            He temperature at peak field point (K).
        bcritsc:
            Critical field at zero temperature and strain (T) (used only if i_tf_superconductor=4).
        tcritsc:
            Critical temperature at zero field and strain (K) (used only if i_tf_superconductor=4).

        Returns
        -------
        type
            tuple (float, float, float, float, float, float, float, float, float)
            - j_tf_wp_critical (float): Critical winding pack current density (A/m²).
            - j_superconductor_critical (float): Critical current density in superconductor (A/m²).
            - f_c_tf_turn_operating_critical (float): Ratio of operating / critical current.
            - j_superconductor_turn (float): Actual current density in superconductor (A/m²).
            - j_tf_coil_turn (float): Actual current density in superconductor (A/m²).
            - b_tf_superconductor_critical_zero_temp_strain (float): Critical field at zero temperature and strain (T).
            - temp_tf_superconductor_critical_zero_field_strain (float): Critical temperature at zero field and strain (K).
            - c_tf_turn_cables_critical (float): Critical current in cable (A).

        Notes
        -----
        This routine calculates the superconductor properties for the TF coils.
        It was originally programmed by J. Galambos (1991), from algorithms provided by J. Miller.
        The routine calculates the critical current density (winding pack) and also the protection
        information (for a quench). Not used for the CroCo conductor.

        The critical current density for a superconductor (``j_superconductor_critical``) is for the superconducting
        strands/tape, not including copper. The critical current density for a cable (``j_crit_cable``)
        accounts for both the fraction of the cable taken up by helium coolant channels, and the cable
        conductor copper fraction (i.e., the copper in the superconducting strands and any additional
        copper, such as REBCO tape support).
        """

        # Guard against negative conductor fraction f_a_tf_turn_cable_space_conductor
        # Kludge to allow solver to continue and hopefully be constrained away
        # from this point
        if f_a_tf_turn_cable_space_cooling > 0.99:
            f_a_tf_turn_cable_space_cooling = 0.99

        #  Conductor fraction (including central helium channel)
        f_a_tf_turn_cable_space_conductor = 1.0e0 - f_a_tf_turn_cable_space_cooling

        if tfcoil_variables.i_str_wp == 0:
            strain = tfcoil_variables.str_tf_con_res
        else:
            strain = tfcoil_variables.str_wp

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

        # ITER Nb3Sn critical surface parameterization
        if i_tf_superconductor == 1:
            # Peak field and temperature at zero strain
            bc20m = 32.97e0  # [T]
            tc0m = 16.06e0  # [K]

            # If strain limit achieved, throw a warning and use the lower strain
            if abs(strain) > 0.5e-2:
                logger.error(
                    f"TF strain={strain} was outside the region of applicability. Used lower strain."
                )
                strain = np.sign(strain) * 0.5e-2

            #  j_superconductor_critical returned by superconductors.itersc is the critical current density in the
            #  superconductor - not the whole strand, which contains copper
            j_superconductor_critical, _, _ = superconductors.itersc(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                strain=strain,
                b_c20max=bc20m,
                temp_c0max=tc0m,
            )

            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calculation for costing in $/kAm
            # = Superconducting filaments jc * (1 - strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

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

        # Bi-2212 high temperature superconductor parameterization
        elif i_tf_superconductor == 2:
            #  Current density in a strand of Bi-2212 conductor
            #  N.B. jcrit returned by superconductors.bi2212 is the critical current density
            #  in the strand, not just the superconducting portion.
            #  The parameterization for j_crit_cable assumes a particular strand
            #  composition that does not require a user-defined copper fraction,
            #  so this is irrelevant in this model
            j_strand = (
                j_tf_wp
                * a_tf_turn
                / (a_tf_turn_cable_space * f_a_tf_turn_cable_space_conductor)
            )

            j_crit_cable, _ = superconductors.bi2212(
                b_conductor=b_tf_inboard_peak,
                jstrand=j_strand,
                temp_conductor=temp_tf_coolant_peak_field,
                f_strain=f_strain_scale,
            )
            j_superconductor_critical = j_crit_cable / (1.0e0 - f_a_tf_turn_cable_copper)
            #  Critical current in cable
            c_turn_cables_critical = (
                j_crit_cable * a_tf_turn_cable_space * f_a_tf_turn_cable_space_conductor
            )

            # Strand critical current calulation for costing in $ / kAm
            # Copper in the strand is already accounted for
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical
        # =================================================================

        # NbTi data
        elif i_tf_superconductor == 3:
            bc20m = 15.0e0  # [T]
            tc0m = 9.3e0  # [K]
            c0 = 1.0e10  # [A/m2]

            j_superconductor_critical, _ = superconductors.jcrit_nbti(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                c0=c0,
                b_c20m=bc20m,
                temp_c0max=tc0m,
            )

            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # = superconducting filaments jc * (1 -strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

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

        # ITER Nb3Sn parameterization, but user-defined parameters
        elif i_tf_superconductor == 4:
            bc20m = bcritsc  # [T]
            tc0m = tcritsc  # [K]

            # If strain limit achieved, throw a warning and use the lower strain
            if abs(strain) > 0.5e-2:
                logger.error(
                    f"TF strain={strain} was outside the region of applicability. Used lower strain."
                )
                strain = np.sign(strain) * 0.5e-2

            j_superconductor_critical, _, _ = superconductors.itersc(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                strain=strain,
                b_c20max=bc20m,
                temp_c0max=tc0m,
            )
            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # = superconducting filaments jc * (1 -strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

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

        # WST Nb3Sn parameterisation
        elif i_tf_superconductor == 5:
            bc20m = 32.97e0  # [T]
            tc0m = 16.06e0  # [K]

            # If strain limit achieved, throw a warning and use the lower strain
            if abs(strain) > 0.5e-2:
                logger.error(
                    f"TF strain={strain} was outside the region of applicability. Used lower strain."
                )
                strain = np.sign(strain) * 0.5e-2

            #  j_superconductor_critical returned by superconductors.itersc is the critical current density in the
            #  superconductor - not the whole strand, which contains copper
            j_superconductor_critical, _, _ = (
                superconductors.western_superconducting_nb3sn(
                    temp_conductor=temp_tf_coolant_peak_field,
                    b_conductor=b_tf_inboard_peak,
                    strain=strain,
                    b_c20max=bc20m,
                    temp_c0max=tc0m,
                )
            )
            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # = superconducting filaments jc * (1 -strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

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

        # "REBCO" 2nd generation HTS superconductor in CrCo strand
        elif i_tf_superconductor == 6:
            raise ProcessValueError(
                "sctfcoil.supercon has been called but tfcoil_variables.i_tf_sc_mat=6"
            )

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

        # Durham Ginzburg-Landau Nb-Ti parameterisation
        elif i_tf_superconductor == 7:
            bc20m = tfcoil_variables.b_crit_upper_nbti  # [T]
            tc0m = tfcoil_variables.t_crit_nbti  # [K]

            j_superconductor_critical, _, _ = superconductors.gl_nbti(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                strain=strain,
                b_c20max=bc20m,
                t_c0=tc0m,
            )
            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # = superconducting filaments jc * (1 -strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

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

        # Durham Ginzburg-Landau critical surface model for REBCO
        elif i_tf_superconductor == 8:
            bc20m = 430  # [T]
            tc0m = 185  # [K]

            # If strain limit achieved, throw a warning and use the lower strain
            if abs(strain) > 0.7e-2:
                logger.error(
                    f"TF strain={strain} was outside the region of applicability. Used lower strain."
                )
                strain = np.sign(strain) * 0.7e-2

            j_superconductor_critical, _, _ = superconductors.gl_rebco(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                strain=strain,
                b_c20max=bc20m,
                t_c0=tc0m,
            )
            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # Already includes buffer and support layers so no need to include f_a_tf_turn_cable_copper here
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical

            # REBCO measurements from 2 T to 14 T, extrapolating outside this
            if (b_tf_inboard_peak) >= 14.0:
                logger.error(
                    "Field on superconductor > 14 T (outside of interpolation range)"
                )

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

        # Hazelton experimental data + Zhai conceptual model for REBCO
        elif i_tf_superconductor == 9:
            bc20m = 138  # [T]
            tc0m = 92  # [K]

            # If strain limit achieved, throw a warning and use the lower strain
            if abs(strain) > 0.7e-2:
                logger.error(
                    f"TF strain={strain} was outside the region of applicability. Used lower strain."
                )
                strain = np.sign(strain) * 0.7e-2

            # 'high current density' as per parameterisation described in Wolf,
            #  and based on Hazelton experimental data and Zhai conceptual model;
            #  see subroutine for full references
            j_superconductor_critical, _, _ = superconductors.hijc_rebco(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                b_c20max=bc20m,
                t_c0=tc0m,
                dr_hts_tape=rebco_variables.dr_hts_tape,
                dx_hts_tape_rebco=rebco_variables.dx_hts_tape_rebco,
                dx_hts_tape_total=rebco_variables.dx_hts_tape_total,
            )
            # Scale for the copper area fraction of the cable
            j_cables_critical = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

            #  Critical current in turn all turn cables
            c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

            # Strand critical current calulation for costing in $ / kAm
            # = superconducting filaments jc * (1 -strand copper fraction)
            tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
                1.0e0 - f_a_tf_turn_cable_copper
            )

        else:
            raise ProcessValueError(
                "Illegal value for i_tf_sc_mat", i_tf_superconductor=i_tf_superconductor
            )

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

        # Critical current density in winding pack
        # a_tf_turn : Area per turn (i.e. entire jacketed conductor with insulation) (m2)
        j_tf_wp_critical = c_turn_cables_critical / a_tf_turn

        #  Ratio of operating / critical current
        f_c_tf_turn_operating_critical = c_tf_turn / c_turn_cables_critical

        #  Operating current density
        j_tf_coil_turn = c_tf_turn / a_tf_turn

        #  Actual current density in superconductor, not including copper

        j_superconductor = f_c_tf_turn_operating_critical * j_superconductor_critical

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

        if f_c_tf_turn_operating_critical <= 0e0:
            logger.error(
                f"""Negative Iop/Icrit for TF coil
            jsc: {j_superconductor}
            f_c_tf_turn_operating_critical: {f_c_tf_turn_operating_critical}
            j_superconductor_critical: {j_superconductor_critical}
            Check conductor dimensions. Cable space area a_tf_turn_cable_space likely gone negative. a_tf_turn_cable_space: {a_tf_turn_cable_space}
            This is likely because dr_tf_turn_cable_space or dx_tf_turn_cable_space has gone negative:
            dr_tf_turn_cable_space: {superconducting_tf_coil_variables.dr_tf_turn_cable_space}
            dx_tf_turn_cable_space: {superconducting_tf_coil_variables.dx_tf_turn_cable_space}
            """
            )

        return (
            j_tf_wp_critical,
            j_superconductor_critical,
            f_c_tf_turn_operating_critical,
            j_superconductor,
            j_tf_coil_turn,
            bc20m,
            tc0m,
            c_turn_cables_critical,
        )

    def calculate_cable_in_conduit_strand_count(
        self,
        a_cable_space: float,
        dia_superconductor_strand: float,
    ) -> int:
        """Calculates the maximum number of superconducting strands that can fit into a cable-in-conduit conductor,
        based on the available cable space, strand diameter, and desired void fraction.

        Parameters
        ----------
        a_cable_space : float
            Total cross-sectional area available for the cable (in m²).
        dia_superconductor_strand : float
            Diameter of a single superconducting strand (in meters).

        Returns
        -------
        int
            The maximum number of strands that can fit in the available space, accounting for the void fraction.
        """

        # Effective area available for strands (excluding voids)
        effective_area = a_cable_space

        # Area per strand (circular)
        strand_area = np.pi * (dia_superconductor_strand / 2) ** 2

        # Number of strands that fit
        return int(effective_area / strand_area)

    def calculate_cable_in_conduit_superconductor_length(
        self,
        n_tf_coils: int,
        n_tf_coil_turns: int,
        len_tf_coil: float,
        n_tf_turn_superconducting_cables: int,
    ) -> float:
        """Calculates the total length of superconducting material required for the TF coils.

        Parameters
        ----------
        n_tf_coils: int :
            n_tf_coils: Number of TF coils.
        n_tf_coil_turns: int :
            n_tf_coil_turns: Total number of turns in the TF coil winding pack.
        len_tf_coil:
            len_tf_coil: Length of a single TF coil (in meters).
        n_tf_turn_superconducting_cables: int :
            n_tf_turn_superconducting_cables: Number of superconducting cables per turn in the TF coil.

        Returns
        -------
        tuple[float, float]
            Tuple containing:
            - Length of superconductor in one TF coil (in meters).
            - Total length of superconductor in all TF coils (in meters).
        """

        # Length of superconductor in one TF coil
        len_tf_coil_superconductor = (
            n_tf_coil_turns * len_tf_coil * n_tf_turn_superconducting_cables
        )

        # Total length of superconductor in all TF coils
        len_tf_superconductor_total = len_tf_coil_superconductor * n_tf_coils

        return len_tf_coil_superconductor, len_tf_superconductor_total

    def output_tf_superconductor_info(self):
        """Output TF superconductor information"""

        po.oheadr(self.outfile, "TF Coils Superconductor Information")
        po.ovarin(
            self.outfile,
            "TF superconductor switch",
            "(i_tf_sc_mat)",
            tfcoil_variables.i_tf_sc_mat,
        )

        po.ocmmnt(
            self.outfile,
            f"Superconductor used: {SUPERCONDUCTING_TF_TYPES[tfcoil_variables.i_tf_sc_mat]}",
        )

        po.ovarre(
            self.outfile,
            "Critical field at zero temperature and strain (T)",
            "(b_tf_superconductor_critical_zero_temp_strain)",
            superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
        )
        po.ovarre(
            self.outfile,
            "Critical temperature at zero field and strain (K)",
            "(temp_tf_superconductor_critical_zero_field_strain)",
            superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
        )

        if global_variables.run_tests == 1:
            po.oblnkl(self.outfile)
            po.ocmmnt(
                self.outfile,
                "PROCESS TF Coil peak field fit. Values for t, z and y:",
            )
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "Dimensionless winding pack width",
                "(tf_fit_t)",
                superconducting_tf_coil_variables.tf_fit_t,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Dimensionless winding pack radial thickness",
                "(tf_fit_z)",
                superconducting_tf_coil_variables.tf_fit_z,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Ratio of peak field with ripple to nominal axisymmetric peak field",
                "(f_b_tf_inboard_peak_ripple_symmetric)",
                superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric,
                "OP ",
            )

        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Helium temperature at peak field (= superconductor temperature) (K)",
            "(tftmp)",
            tfcoil_variables.tftmp,
        )
        po.ovarre(
            self.outfile,
            "Total cooling area fraction inside cable space",
            "(f_a_tf_turn_cable_space_cooling)",
            superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Copper fraction of conductor",
            "(f_a_tf_turn_cable_copper)",
            tfcoil_variables.f_a_tf_turn_cable_copper,
        )
        po.ovarre(
            self.outfile,
            "Residual manufacturing strain on superconductor",
            "(str_tf_con_res)",
            tfcoil_variables.str_tf_con_res,
        )
        po.ovarre(
            self.outfile,
            "Self-consistent strain on superconductor",
            "(str_wp)",
            tfcoil_variables.str_wp,
        )
        po.ovarre(
            self.outfile,
            "Critical current density in superconductor (A/m2)",
            "(j_tf_superconductor_critical)",
            superconducting_tf_coil_variables.j_tf_superconductor_critical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Critical current density in winding pack (A/m2)",
            "(j_tf_wp_critical)",
            tfcoil_variables.j_tf_wp_critical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Actual current density in winding pack (A/m2)",
            "(j_tf_coil_turn)",
            superconducting_tf_coil_variables.j_tf_coil_turn,
            "OP ",
        )

        po.ovarre(
            self.outfile,
            "Minimum allowed temperature margin in superconductor (K)",
            "(temp_tf_superconductor_margin_min)",
            tfcoil_variables.temp_tf_superconductor_margin_min,
        )
        po.ovarre(
            self.outfile,
            "Actual temperature margin in superconductor (K)",
            "(temp_tf_superconductor_margin)",
            tfcoil_variables.temp_tf_superconductor_margin,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Critical current (A)",
            "(c_turn_cables_critical)",
            superconducting_tf_coil_variables.c_tf_turn_cables_critical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Actual current (A)",
            "(c_tf_turn)",
            tfcoil_variables.c_tf_turn,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Actual current / critical current",
            "(f_c_tf_turn_operating_critical)",
            superconducting_tf_coil_variables.f_c_tf_turn_operating_critical,
            "OP ",
        )
        if superconducting_tf_coil_variables.f_c_tf_turn_operating_critical > 0.7:
            logger.error(
                "f_c_tf_turn_operating_critical shouldn't be above 0.7 for engineering reliability"
            )

        po.ovarre(
            self.outfile,
            "TF Superconductor quench dump time (s)",
            "(t_tf_superconductor_quench)",
            tfcoil_variables.t_tf_superconductor_quench,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "TF Superconductor quench detection time (s)",
            "(t_tf_quench_detection)",
            tfcoil_variables.t_tf_quench_detection,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Maximum winding pack current density for protection (A/m2)",
            "(j_tf_wp_quench_heat_max)",
            tfcoil_variables.j_tf_wp_quench_heat_max,
            "OP ",
        )

    def calculate_superconductor_temperature_margin(
        self,
        i_tf_superconductor: int,
        j_superconductor: float,
        b_tf_inboard_peak: float,
        strain: float,
        bc20m: float,
        tc0m: float,
        c0: float,
        temp_tf_coolant_peak_field: float,
    ):
        """Calculate the temperature margin of the TF superconductor.

        Parameters
        ----------
        i_tf_superconductor:
            Switch for conductor type:
            - 1: ITER Nb3Sn, standard parameters
            - 2: Bi-2212 High Temperature Superconductor
            - 3: NbTi
            - 4: ITER Nb3Sn, user-defined parameters
            - 5: WST Nb3Sn parameterisation
            - 7: Durham Ginzburg-Landau Nb-Ti parameterisation
            - 8: Durham Ginzburg-Landau critical surface model for REBCO
            - 9: Hazelton experimental data + Zhai conceptual model for REBCO
        j_superconductor:
            Current density in superconductor (A/m²).
        b_tf_inboard_peak:
            Peak field at conductor (T).
        strain:
            Strain on superconductor.
        bc20m:
            Critical field at zero temperature and strain (T).
        tc0m:
            Critical temperature at zero field and strain (K).
        c0:
            Constant used in NbTi critical current density calculation (A/m²).
        temp_tf_coolant_peak_field:
            He temperature at peak field point (K).

        Returns
        -------
        type
            temp_tf_superconductor_margin.
        """

        # =================================================================
        # Calculate temperature margin of superconductor

        #  Temperature margin (already calculated in superconductors.bi2212 for i_tf_superconductor=2)

        if i_tf_superconductor in (
            1,
            3,
            4,
            5,
            7,
            8,
            9,
        ):  # Find temperature at which current density margin = 0
            if i_tf_superconductor == 3:
                arguments = (
                    i_tf_superconductor,
                    j_superconductor,
                    b_tf_inboard_peak,
                    strain,
                    bc20m,
                    tc0m,
                    c0,
                )
            else:
                arguments = (
                    i_tf_superconductor,
                    j_superconductor,
                    b_tf_inboard_peak,
                    strain,
                    bc20m,
                    tc0m,
                )

            another_estimate = 2 * temp_tf_coolant_peak_field
            (
                t_zero_margin,
                _root_result,
            ) = optimize.newton(
                superconductors.superconductor_current_density_margin,
                temp_tf_coolant_peak_field,
                fprime=None,
                args=arguments,
                tol=1.0e-06,
                maxiter=50,
                fprime2=None,
                x1=another_estimate,
                rtol=1.0e-6,
                full_output=True,
                disp=True,
            )
            # print(root_result)  # Diagnostic for newton method
            temp_tf_superconductor_margin = t_zero_margin - temp_tf_coolant_peak_field
            tfcoil_variables.temp_margin = temp_tf_superconductor_margin

            if temp_tf_superconductor_margin <= 0.0e0:
                logger.error(
                    """Negative TFC temperature margin
                temp_tf_superconductor_margin: {temp_tf_superconductor_margin}
                b_tf_inboard_peak: {b_tf_inboard_peak}
                j_superconductor: {j_superconductor}
                """
                )

        return temp_tf_superconductor_margin

    def quench_heat_protection_current_density(
        self,
        c_tf_turn: float,
        e_tf_coil_magnetic_stored: float,
        a_tf_turn_cable_space: float,
        a_tf_turn: float,
        t_tf_quench_dump: float,
        f_a_tf_turn_cable_space_conductor: float,
        f_a_tf_turn_cable_copper: float,
        temp_tf_coolant_peak_field: float,
        temp_tf_conductor_quench_max: float,
        b_tf_inboard_peak: float,
        cu_rrr: float,
        t_tf_quench_detection: float,
        nflutfmax: float,
    ) -> tuple[float, float]:
        """Calculates the maximum conductor current density limited by the protection limit,
        and the discharge voltage for a TF coil.

        Parameters
        ----------
        c_tf_turn : float
            Operating current (A)
        e_tf_coil_magnetic_stored : float
            Energy stored in one TF coil (J)
        a_tf_turn_cable_space : float
            Cable space - inside area (m²)
        a_tf_turn : float
            Area per turn (i.e. entire cable) (m²)
        t_tf_quench_dump : float
            Dump time (s)
        f_a_tf_turn_cable_space_conductor : float
            Fraction of cable space containing conductor
        f_a_tf_turn_cable_copper : float
            Fraction of conductor that is copper
        temp_tf_coolant_peak_field : float
            Helium temperature at peak field point (K)
        temp_tf_conductor_quench_max : float
            Maximum conductor temperature during quench (K)
        b_tf_inboard_peak : float
            Peak magnetic field at conductor (T)
        cu_rrr : float
            Copper residual-resistance-ratio
        t_tf_quench_detection : float
            Quench detection time (s)
        nflutfmax : float
            End-of-life neutron fluence in the copper (1/m²)

        Returns
        -------
        tuple[float, float]
            j_tf_wp_quench_protection_max (float): Winding pack current density from temperature rise protection (A/m²)
            - v_tf_dump_voltage_peak (float): Discharge voltage imposed on a TF coil (V)

        References
        ----------
        - L. Bottura, “Magnet Quench 101,” arXiv (Cornell University), Jan. 2014,
        doi: https://doi.org/10.48550/arxiv.1401.3927.
        """

        #  Peak Dump voltage
        v_tf_dump_voltage_peak = (
            2.0e0 * e_tf_coil_magnetic_stored / (t_tf_quench_dump * c_tf_turn)
        )

        # Winding pack current density from temperature rise protection
        j_tf_wp_quench_protection_max = (
            a_tf_turn_cable_space
            / a_tf_turn
            * quench.calculate_quench_protection_current_density(
                t_tf_quench_dump,
                b_tf_inboard_peak,
                f_a_tf_turn_cable_copper,
                1.0 - f_a_tf_turn_cable_space_conductor,
                temp_tf_coolant_peak_field,
                temp_tf_conductor_quench_max,
                cu_rrr,
                t_tf_quench_detection,
                nflutfmax,
            )
        )

        return j_tf_wp_quench_protection_max, v_tf_dump_voltage_peak

    def vv_stress_on_quench(self):
        """Calculate the Tresca stress [Pa] of the Vacuum Vessel (VV)
        experienced when the TF coil quenches.

        Assumes the current center line (CCL) of the TF coil is the
        middle of the coil.

        We assume vertical symmetry which is only true for double null
        machines.
        """
        H_coil = build_variables.z_tf_inside_half + (build_variables.dr_tf_inboard / 2)
        ri_coil = build_variables.r_tf_inboard_mid
        ro_coil = build_variables.r_tf_outboard_mid
        # NOTE: rm is measured from the outside edge of the coil because thats where
        # the radius of the first ellipse is measured from
        rm_coil = build_variables.r_tf_inboard_out + tfcoil_variables.tfa[0]

        H_vv = (
            build_variables.z_plasma_xpoint_upper
            + build_variables.dz_xpoint_divertor
            + divertor_variables.dz_divertor
            + build_variables.dz_shld_upper
            + (build_variables.dz_vv_upper / 2)
        )
        # ri and ro for VV dont consider the shield widths
        # because it is assumed the shield is on the plasma side
        # of the VV
        ri_vv = build_variables.r_vv_inboard_out - (build_variables.dr_vv_outboard / 2)
        ro_vv = (
            build_variables.r_tf_outboard_mid
            - (build_variables.dr_tf_outboard / 2)
            - build_variables.dr_tf_shld_gap
            - build_variables.dr_shld_thermal_outboard
            - build_variables.dr_shld_vv_gap_outboard
            - (build_variables.dr_vv_outboard / 2)
        )

        # Assume the radius of the first ellipse of the VV is in the same proportion to
        # that of the plasma facing radii of the two structures
        tf_vv_frac = build_variables.r_tf_inboard_out / build_variables.r_vv_inboard_out
        rm_vv = build_variables.r_vv_inboard_out + (tfcoil_variables.tfa[0] * tf_vv_frac)

        superconducting_tf_coil_variables.vv_stress_quench = vv_stress_on_quench(
            # TF shape
            H_coil=H_coil,
            ri_coil=ri_coil,
            ro_coil=ro_coil,
            rm_coil=rm_coil,
            ccl_length_coil=tfcoil_variables.len_tf_coil,
            theta1_coil=tfcoil_variables.theta1_coil,
            # VV shape
            H_vv=H_vv,
            ri_vv=ri_vv,
            ro_vv=ro_vv,
            rm_vv=rm_vv,
            theta1_vv=tfcoil_variables.theta1_vv,
            # TF properties
            n_tf_coils=tfcoil_variables.n_tf_coils,
            n_tf_coil_turns=tfcoil_variables.n_tf_coil_turns,
            # Area of the radial plate taken to be the area of steel in the WP
            # TODO: value clipped due to #1883
            s_rp=np.clip(
                superconducting_tf_coil_variables.a_tf_coil_inboard_steel, 0, None
            ),
            s_cc=superconducting_tf_coil_variables.a_tf_plasma_case
            + superconducting_tf_coil_variables.a_tf_coil_nose_case
            + 2.0 * superconducting_tf_coil_variables.dx_tf_side_case_average,
            taud=tfcoil_variables.t_tf_superconductor_quench,
            # TODO: is this the correct current?
            i_op=superconducting_tf_coil_variables.c_tf_coil
            / tfcoil_variables.n_tf_coil_turns,
            # VV properties
            d_vv=build_variables.dr_vv_shells,
        )

    def peak_b_tf_inboard_with_ripple(
        self,
        n_tf_coils: float,
        dx_tf_wp_primary_toroidal: float,
        dr_tf_wp_no_insulation: float,
        r_tf_wp_inboard_centre: float,
        b_tf_inboard_peak_symmetric: float,
    ) -> tuple[float, int]:
        """Calculates the peak toroidal field at the outboard edge of the inboard TF coil winding pack,
        including the effects of ripple.

        For 16, 18, or 20 coils, uses fitting formulae derived by M. Kovari using MAGINT calculations
        on coil sets based on a DEMO1 case. For other numbers of coils, uses a 9% increase due to ripple
        from the axisymmetric calculation.

        Parameters
        ----------
        n_tf_coils : float
            Number of TF coils.
        dx_tf_wp_primary_toroidal : float
            Width of plasma-facing face of winding pack (m).
        dr_tf_wp_no_insulation : float
            Radial thickness of winding pack with no insulation (e.g. conductor region) (m).
        r_tf_wp_inboard_centre : float
            Major radius of centre of winding pack (m).
        b_tf_inboard_peak_symmetric : float
            Nominal (axisymmetric) peak toroidal field (T).

        Returns
        -------
        tuple[float]
            Tuple containing:
            - b_tf_inboard_peak_with_ripple (float): Peak toroidal field including ripple (T).

        Notes
        -----
        - M. Kovari, Toroidal Field Coils - Maximum Field and Ripple - Parametric Calculation, July 2014.
        """
        a = np.zeros((4,))

        #  Set fitting coefficients for different numbers of TF coils

        int_n_tf = np.round(n_tf_coils)

        if int_n_tf == 16:
            a[0] = 0.28101e0
            a[1] = 1.8481e0
            a[2] = -0.88159e0
            a[3] = 0.93834e0
        elif int_n_tf == 18:
            a[0] = 0.29153e0
            a[1] = 1.81600e0
            a[2] = -0.84178e0
            a[3] = 0.90426e0
        elif int_n_tf == 20:
            a[0] = 0.29853e0
            a[1] = 1.82130e0
            a[2] = -0.85031e0
            a[3] = 0.89808e0

        else:
            return 1.09e0 * b_tf_inboard_peak_symmetric

        #  Maximum winding pack width before adjacent packs touch
        #  (ignoring the external case and ground wall thicknesses)

        dx_tf_wp_toroidal_max = (
            2.0e0 * r_tf_wp_inboard_centre + dr_tf_wp_no_insulation
        ) * np.tan(np.pi / n_tf_coils)

        #  Dimensionless winding pack width

        superconducting_tf_coil_variables.tf_fit_t = (
            dx_tf_wp_primary_toroidal / dx_tf_wp_toroidal_max
        )
        if (superconducting_tf_coil_variables.tf_fit_t < 0.3e0) or (
            superconducting_tf_coil_variables.tf_fit_t > 1.1e0
        ):
            logger.warning(
                "(TF coil peak field calculation) Winding pack width out of fitted range"
            )

        #  Dimensionless winding pack radial thickness

        superconducting_tf_coil_variables.tf_fit_z = (
            dr_tf_wp_no_insulation / dx_tf_wp_toroidal_max
        )
        if (superconducting_tf_coil_variables.tf_fit_z < 0.26e0) or (
            superconducting_tf_coil_variables.tf_fit_z > 0.7e0
        ):
            # write(*,*) 'PEAK_TF_WITH_RIPPLE: fitting problem; z = ',z
            logger.warning(
                "(TF coil peak field calculation) Winding pack radial thickness out of fitted range"
            )

        #  Ratio of peak field with ripple to nominal axisymmetric peak field

        superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric = (
            a[0]
            + a[1] * np.exp(-superconducting_tf_coil_variables.tf_fit_t)
            + a[2] * superconducting_tf_coil_variables.tf_fit_z
            + a[3]
            * superconducting_tf_coil_variables.tf_fit_z
            * superconducting_tf_coil_variables.tf_fit_t
        )

        return (
            superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric
            * b_tf_inboard_peak_symmetric
        )

    def sc_tf_internal_geom(self, i_tf_wp_geom, i_tf_case_geom, i_tf_turns_integer):
        """
        Seting the WP, case and turns geometry for SC magnets

        Parameters
        ----------
        i_tf_wp_geom :

        i_tf_case_geom :

        i_tf_turns_integer :

        """

        # Calculating the WP / ground insulation areas
        (
            superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
            superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
            superconducting_tf_coil_variables.r_tf_wp_inboard_centre,
            superconducting_tf_coil_variables.dx_tf_wp_toroidal_min,
            superconducting_tf_coil_variables.dr_tf_wp_no_insulation,
            tfcoil_variables.dx_tf_wp_primary_toroidal,
            tfcoil_variables.dx_tf_wp_secondary_toroidal,
            superconducting_tf_coil_variables.dx_tf_wp_toroidal_average,
            superconducting_tf_coil_variables.a_tf_wp_with_insulation,
            superconducting_tf_coil_variables.a_tf_wp_no_insulation,
            superconducting_tf_coil_variables.a_tf_wp_ground_insulation,
        ) = self.superconducting_tf_wp_geometry(
            i_tf_wp_geom=i_tf_wp_geom,
            r_tf_inboard_in=build_variables.r_tf_inboard_in,
            dr_tf_nose_case=tfcoil_variables.dr_tf_nose_case,
            dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
            tan_theta_coil=superconducting_tf_coil_variables.tan_theta_coil,
            dx_tf_side_case_min=tfcoil_variables.dx_tf_side_case_min,
            dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
            dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
        )

        # Calculating the TF steel casing areas
        (
            tfcoil_variables.a_tf_coil_inboard_case,
            tfcoil_variables.a_tf_coil_outboard_case,
            superconducting_tf_coil_variables.a_tf_plasma_case,
            superconducting_tf_coil_variables.a_tf_coil_nose_case,
            superconducting_tf_coil_variables.dx_tf_side_case_average,
            superconducting_tf_coil_variables.dx_tf_side_case_peak,
        ) = self.superconducting_tf_case_geometry(
            i_tf_case_geom=i_tf_case_geom,
            i_tf_wp_geom=i_tf_wp_geom,
            a_tf_inboard_total=tfcoil_variables.a_tf_inboard_total,
            n_tf_coils=tfcoil_variables.n_tf_coils,
            a_tf_wp_with_insulation=superconducting_tf_coil_variables.a_tf_wp_with_insulation,
            a_tf_leg_outboard=tfcoil_variables.a_tf_leg_outboard,
            rad_tf_coil_inboard_toroidal_half=superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half,
            r_tf_inboard_out=build_variables.r_tf_inboard_out,
            tan_theta_coil=superconducting_tf_coil_variables.tan_theta_coil,
            r_tf_wp_inboard_outer=superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
            dr_tf_plasma_case=tfcoil_variables.dr_tf_plasma_case,
            r_tf_wp_inboard_inner=superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
            r_tf_inboard_in=build_variables.r_tf_inboard_in,
            dx_tf_side_case_min=tfcoil_variables.dx_tf_side_case_min,
            dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
        )

        # WP/trun currents
        self.tf_wp_currents()

        # Setting the WP turn geometry / areas
        if i_tf_turns_integer == 0:
            # Non-ingeger number of turns
            (
                tfcoil_variables.a_tf_turn_cable_space_no_void,
                tfcoil_variables.a_tf_turn_steel,
                tfcoil_variables.a_tf_turn_insulation,
                tfcoil_variables.n_tf_coil_turns,
                tfcoil_variables.dx_tf_turn_general,
                tfcoil_variables.c_tf_turn,
                tfcoil_variables.dx_tf_turn_general,
                superconducting_tf_coil_variables.dr_tf_turn,
                superconducting_tf_coil_variables.dx_tf_turn,
                tfcoil_variables.t_conductor,
                superconducting_tf_coil_variables.radius_tf_turn_cable_space_corners,
                superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
                superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
                superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
            ) = self.tf_cable_in_conduit_averaged_turn_geometry(
                j_tf_wp=tfcoil_variables.j_tf_wp,
                dx_tf_turn_steel=tfcoil_variables.dx_tf_turn_steel,
                dx_tf_turn_insulation=tfcoil_variables.dx_tf_turn_insulation,
                i_tf_sc_mat=tfcoil_variables.i_tf_sc_mat,
                dx_tf_turn_general=tfcoil_variables.dx_tf_turn_general,
                c_tf_turn=tfcoil_variables.c_tf_turn,
                i_dx_tf_turn_general_input=tfcoil_variables.i_dx_tf_turn_general_input,
                i_dx_tf_turn_cable_space_general_input=tfcoil_variables.i_dx_tf_turn_cable_space_general_input,
                dx_tf_turn_cable_space_general=tfcoil_variables.dx_tf_turn_cable_space_general,
                layer_ins=tfcoil_variables.layer_ins,
                a_tf_wp_no_insulation=superconducting_tf_coil_variables.a_tf_wp_no_insulation,
                dia_tf_turn_coolant_channel=tfcoil_variables.dia_tf_turn_coolant_channel,
                f_a_tf_turn_cable_space_extra_void=tfcoil_variables.f_a_tf_turn_cable_space_extra_void,
            )

        else:
            # Integer number of turns
            (
                superconducting_tf_coil_variables.radius_tf_turn_cable_space_corners,
                superconducting_tf_coil_variables.dr_tf_turn,
                superconducting_tf_coil_variables.dx_tf_turn,
                tfcoil_variables.a_tf_turn_cable_space_no_void,
                tfcoil_variables.a_tf_turn_steel,
                tfcoil_variables.a_tf_turn_insulation,
                tfcoil_variables.c_tf_turn,
                tfcoil_variables.n_tf_coil_turns,
                superconducting_tf_coil_variables.t_conductor_radial,
                superconducting_tf_coil_variables.t_conductor_toroidal,
                tfcoil_variables.t_conductor,
                superconducting_tf_coil_variables.dr_tf_turn_cable_space,
                superconducting_tf_coil_variables.dx_tf_turn_cable_space,
                superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
            ) = self.tf_cable_in_conduit_integer_turn_geometry(
                dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
                dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
                dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
                n_tf_wp_layers=tfcoil_variables.n_tf_wp_layers,
                dx_tf_wp_toroidal_min=superconducting_tf_coil_variables.dx_tf_wp_toroidal_min,
                n_tf_wp_pancakes=tfcoil_variables.n_tf_wp_pancakes,
                c_tf_coil=superconducting_tf_coil_variables.c_tf_coil,
                dx_tf_turn_steel=tfcoil_variables.dx_tf_turn_steel,
                dx_tf_turn_insulation=tfcoil_variables.dx_tf_turn_insulation,
            )

        # Calculate number of cables in turn if CICC conductor
        # ---------------------------------------------------
        if tfcoil_variables.i_tf_sc_mat != 6:
            superconducting_tf_coil_variables.n_tf_turn_superconducting_cables = self.calculate_cable_in_conduit_strand_count(
                a_cable_space=superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
                dia_superconductor_strand=superconducting_tf_coil_variables.dia_tf_turn_superconducting_cable,
            )

            (
                superconducting_tf_coil_variables.len_tf_coil_superconductor,
                superconducting_tf_coil_variables.len_tf_superconductor_total,
            ) = self.calculate_cable_in_conduit_superconductor_length(
                n_tf_coils=tfcoil_variables.n_tf_coils,
                n_tf_coil_turns=tfcoil_variables.n_tf_coil_turns,
                len_tf_coil=tfcoil_variables.len_tf_coil,
                n_tf_turn_superconducting_cables=superconducting_tf_coil_variables.n_tf_turn_superconducting_cables,
            )

        # Areas and fractions
        # -------------------
        # Central helium channel down the conductor core [m2]
        tfcoil_variables.a_tf_wp_coolant_channels = (
            0.25e0
            * tfcoil_variables.n_tf_coil_turns
            * np.pi
            * tfcoil_variables.dia_tf_turn_coolant_channel**2
        )

        # Total conductor cross-sectional area, taking account of void area
        # and central helium channel [m2]
        tfcoil_variables.a_tf_wp_conductor = (
            tfcoil_variables.a_tf_turn_cable_space_no_void
            * tfcoil_variables.n_tf_coil_turns
            * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
            - tfcoil_variables.a_tf_wp_coolant_channels
        )

        # Void area in conductor for He, not including central channel [m2]
        tfcoil_variables.a_tf_wp_extra_void = (
            tfcoil_variables.a_tf_turn_cable_space_no_void
            * tfcoil_variables.n_tf_coil_turns
            * tfcoil_variables.f_a_tf_turn_cable_space_extra_void
        )

        # Area of inter-turn insulation: total [m2]
        tfcoil_variables.a_tf_coil_wp_turn_insulation = (
            tfcoil_variables.n_tf_coil_turns * tfcoil_variables.a_tf_turn_insulation
        )

        # Area of steel structure in winding pack [m2]
        tfcoil_variables.a_tf_wp_steel = (
            tfcoil_variables.n_tf_coil_turns * tfcoil_variables.a_tf_turn_steel
        )

        # Inboard coil steel area [m2]
        superconducting_tf_coil_variables.a_tf_coil_inboard_steel = (
            tfcoil_variables.a_tf_coil_inboard_case + tfcoil_variables.a_tf_wp_steel
        )

        # Inboard coil steel fraction [-]
        superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel = (
            tfcoil_variables.n_tf_coils
            * superconducting_tf_coil_variables.a_tf_coil_inboard_steel
            / tfcoil_variables.a_tf_inboard_total
        )

        # Inboard coil insulation cross-section [m2]
        superconducting_tf_coil_variables.a_tf_coil_inboard_insulation = (
            tfcoil_variables.a_tf_coil_wp_turn_insulation
            + superconducting_tf_coil_variables.a_tf_wp_ground_insulation
        )

        #  Inboard coil insulation fraction [-]
        superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation = (
            tfcoil_variables.n_tf_coils
            * superconducting_tf_coil_variables.a_tf_coil_inboard_insulation
            / tfcoil_variables.a_tf_inboard_total
        )

        # Negative areas or fractions error reporting
        if (
            tfcoil_variables.a_tf_wp_conductor <= 0.0e0
            or tfcoil_variables.a_tf_wp_extra_void <= 0.0e0
            or tfcoil_variables.a_tf_coil_wp_turn_insulation <= 0.0e0
            or tfcoil_variables.a_tf_wp_steel <= 0.0e0
            or superconducting_tf_coil_variables.a_tf_coil_inboard_steel <= 0.0e0
            or superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel <= 0.0e0
            or superconducting_tf_coil_variables.a_tf_coil_inboard_insulation <= 0.0e0
            or superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation <= 0.0e0
        ):
            logger.error(
                "One of the areas or fractions is negative in the internal SC TF coil geometry"
                f"{tfcoil_variables.a_tf_wp_conductor=} {tfcoil_variables.a_tf_wp_extra_void=}"
                f"{tfcoil_variables.a_tf_coil_wp_turn_insulation=} {tfcoil_variables.a_tf_wp_steel=}"
                f"{superconducting_tf_coil_variables.a_tf_coil_inboard_steel=} {superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel=}"
                f"{superconducting_tf_coil_variables.a_tf_coil_inboard_insulation=} {superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation=}"
            )

    def superconducting_tf_wp_geometry(
        self,
        i_tf_wp_geom: int,
        r_tf_inboard_in: float,
        dr_tf_nose_case: float,
        dr_tf_wp_with_insulation: float,
        tan_theta_coil: float,
        dx_tf_side_case_min: float,
        dx_tf_wp_insulation: float,
        dx_tf_wp_insertion_gap: float,
    ) -> tuple[
        float,  # r_tf_wp_inboard_inner
        float,  # r_tf_wp_inboard_outer
        float,  # r_tf_wp_inboard_centre
        float,  # dx_tf_wp_toroidal_min
        float,  # dr_tf_wp_no_insulation
        float,  # dx_tf_wp_primary_toroidal
        float,  # dx_tf_wp_secondary_toroidal
        float,  # dx_tf_wp_toroidal_average
        float,  # a_tf_wp_with_insulation
        float,  # a_tf_wp_no_insulation
        float,  # a_tf_wp_ground_insulation
    ]:
        """Calculates the winding pack (WP) geometry and cross-sectional areas for superconducting toroidal field (TF) coils.

        Parameters
        ----------
        i_tf_wp_geom : int
            0: Rectangular
            - 1: Double rectangular
            - 2: Trapezoidal
        r_tf_inboard_in : float
            Inboard inner radius [m].
        dr_tf_nose_case : float
            Radial thickness of nose case [m].
        dr_tf_wp_with_insulation : float
            Radial thickness of winding pack including insulation [m].
        tan_theta_coil : float
            Tangent of coil half angle [-].
        dx_tf_side_case_min : float
            Side case thickness [m].
        dx_tf_wp_insulation : float
            Insulation thickness [m].
        dx_tf_wp_insertion_gap : float
            Insertion gap thickness [m].

        Returns
        -------
        tuple[float, float, float, float, float, float, float, float, float, float]
            Tuple containing:
            - r_tf_wp_inboard_inner (float): WP inboard inner radius [m]
            - r_tf_wp_inboard_outer (float): WP inboard outer radius [m]
            - r_tf_wp_inboard_centre (float): WP inboard centre radius [m]
            - dx_tf_wp_toroidal_min (float): Minimal toroidal thickness of WP [m]
            - dr_tf_wp_no_insulation (float): Radial thickness of winding pack without insulation [m]
            - dx_tf_wp_primary_toroidal (float): Primary toroidal thickness [m]
            - dx_tf_wp_secondary_toroidal (float): Secondary toroidal thickness [m]
            - dx_tf_wp_toroidal_average (float): Averaged toroidal thickness [m]
            - a_tf_wp_with_insulation (float): WP cross-sectional area with insulation [m²]
            - a_tf_wp_no_insulation (float): WP cross-sectional area without insulation [m²]
            - a_tf_wp_ground_insulation (float): WP ground insulation cross-sectional area [m²]

        Raises
        ------
        ValueError
            If calculated winding pack area (with or without insulation) is non-positive.
        """

        r_tf_wp_inboard_inner = r_tf_inboard_in + dr_tf_nose_case

        # Radial position of outer edge of winding pack [m]
        r_tf_wp_inboard_outer = r_tf_wp_inboard_inner + dr_tf_wp_with_insulation

        # Radius of geometrical centre of winding pack [m]
        r_tf_wp_inboard_centre = 0.5e0 * (r_tf_wp_inboard_inner + r_tf_wp_inboard_outer)

        # TF toroidal thickness at the WP inner radius [m]
        dx_tf_wp_inner_toroidal = 2.0e0 * r_tf_wp_inboard_inner * tan_theta_coil

        # Minimal toroidal thickness of winding pack [m]
        dx_tf_wp_toroidal_min = dx_tf_wp_inner_toroidal - 2.0e0 * dx_tf_side_case_min

        # Radial thickness of winding pack without insulation (e.g. the conductor region) [m]
        dr_tf_wp_no_insulation = dr_tf_wp_with_insulation - 2.0e0 * (
            dx_tf_wp_insulation + dx_tf_wp_insertion_gap
        )

        # Rectangular WP
        # --------------
        if i_tf_wp_geom == 0:
            # Outer WP layer toroidal thickness [m]
            dx_tf_wp_primary_toroidal = dx_tf_wp_toroidal_min

            # No secondary WP here but will set for consistency
            dx_tf_wp_secondary_toroidal = dx_tf_wp_toroidal_min

            # Averaged toroidal thickness of of winding pack [m]
            dx_tf_wp_toroidal_average = dx_tf_wp_toroidal_min

            # Total cross-sectional area of winding pack [m²]
            a_tf_wp_with_insulation = (
                dr_tf_wp_with_insulation * dx_tf_wp_primary_toroidal
            )

            # WP cross-section without insertion gap and ground insulation [m²]
            a_tf_wp_no_insulation = (
                dr_tf_wp_with_insulation
                - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
            ) * (
                dx_tf_wp_primary_toroidal
                - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
            )

            # Cross-section area of the WP ground insulation [m²]
            a_tf_wp_ground_insulation = (
                dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap
            ) * (
                dx_tf_wp_primary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap
            ) - a_tf_wp_no_insulation

        # Double rectangular WP
        # ---------------------
        elif i_tf_wp_geom == 1:
            # Thickness of winding pack section at R > superconducting_tf_coil_variables.r_tf_wp_inboard_centre [m]
            dx_tf_wp_primary_toroidal = 2.0e0 * (
                r_tf_wp_inboard_centre * tan_theta_coil - dx_tf_side_case_min
            )

            # Thickness of winding pack section at R < superconducting_tf_coil_variables.r_tf_wp_inboard_centre [m]
            dx_tf_wp_secondary_toroidal = 2.0e0 * (
                r_tf_wp_inboard_inner * tan_theta_coil - dx_tf_side_case_min
            )

            # Averaged toroidal thickness of of winding pack [m]
            dx_tf_wp_toroidal_average = 0.5e0 * (
                dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal
            )

            # Total cross-sectional area of winding pack [m²]
            # Including ground insulation and insertion gap
            a_tf_wp_with_insulation = (
                dr_tf_wp_with_insulation * dx_tf_wp_toroidal_average
            )

            # WP cross-section without insertion gap and ground insulation [m²]
            a_tf_wp_no_insulation = (
                0.5e0
                * (
                    dr_tf_wp_with_insulation
                    - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                )
                * (
                    dx_tf_wp_primary_toroidal
                    + dx_tf_wp_secondary_toroidal
                    - 4.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                )
            )

            # Cross-section area of the WP ground insulation [m²]
            a_tf_wp_ground_insulation = (
                0.5e0
                * (dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap)
                * (
                    dx_tf_wp_primary_toroidal
                    + dx_tf_wp_secondary_toroidal
                    - 4.0e0 * dx_tf_wp_insertion_gap
                )
                - a_tf_wp_no_insulation
            )

        # Trapezoidal WP
        # --------------
        else:
            # Thickness of winding pack section at r_tf_wp_inboard_outer [m]
            dx_tf_wp_primary_toroidal = 2.0e0 * (
                r_tf_wp_inboard_outer * tan_theta_coil - dx_tf_side_case_min
            )

            # Thickness of winding pack section at r_tf_wp_inboard_inner [m]
            dx_tf_wp_secondary_toroidal = 2.0e0 * (
                r_tf_wp_inboard_inner * tan_theta_coil - dx_tf_side_case_min
            )

            # Averaged toroidal thickness of of winding pack [m]
            dx_tf_wp_toroidal_average = 0.5e0 * (
                dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal
            )

            # Total cross-sectional area of winding pack [m²]
            # Including ground insulation and insertion gap
            a_tf_wp_with_insulation = (
                dr_tf_wp_with_insulation
                * 0.5
                * (dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal)
            )

            # WP cross-section without insertion gap and ground insulation [m²]
            a_tf_wp_no_insulation = (
                (
                    dr_tf_wp_with_insulation
                    - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                )
                * (
                    (
                        dx_tf_wp_secondary_toroidal
                        - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                    )
                    + (
                        dx_tf_wp_primary_toroidal
                        - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                    )
                )
                / 2
            )

            # Cross-section area of the WP ground insulation [m²]
            a_tf_wp_ground_insulation = (
                dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap
            ) * (
                (
                    (dx_tf_wp_primary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap)
                    + (dx_tf_wp_secondary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap)
                )
                / 2
            ) - a_tf_wp_no_insulation

        # --------------
        # Negative WP area error reporting
        if a_tf_wp_no_insulation <= 0.0e0 or a_tf_wp_with_insulation <= 0.0e0:
            logger.error(
                f"Winding pack cross-section problem... {a_tf_wp_no_insulation=} {a_tf_wp_with_insulation=}"
            )

        return (
            r_tf_wp_inboard_inner,
            r_tf_wp_inboard_outer,
            r_tf_wp_inboard_centre,
            dx_tf_wp_toroidal_min,
            dr_tf_wp_no_insulation,
            dx_tf_wp_primary_toroidal,
            dx_tf_wp_secondary_toroidal,
            dx_tf_wp_toroidal_average,
            a_tf_wp_with_insulation,
            a_tf_wp_no_insulation,
            a_tf_wp_ground_insulation,
        )

    def superconducting_tf_case_geometry(
        self,
        i_tf_wp_geom: int,
        i_tf_case_geom: int,
        a_tf_inboard_total: float,
        n_tf_coils: float,
        a_tf_wp_with_insulation: float,
        a_tf_leg_outboard: float,
        rad_tf_coil_inboard_toroidal_half: float,
        r_tf_inboard_out: float,
        tan_theta_coil: float,
        r_tf_wp_inboard_outer: float,
        dr_tf_plasma_case: float,
        r_tf_wp_inboard_inner: float,
        r_tf_inboard_in: float,
        dx_tf_side_case_min: float,
        dr_tf_wp_with_insulation: float,
    ) -> tuple[float, float, float, float, float, float]:
        """Setting the case geometry and area for SC magnets

        Parameters
        ----------
        i_tf_wp_geom : int
            Index specifying winding pack geometry (0: rectangular, 1: double rectangular, else: trapezoidal).
        i_tf_case_geom : int
            Index specifying case geometry (0: circular, else: straight).
        a_tf_inboard_total : float
            Total inboard area for TF coils [m²].
        n_tf_coils : float
            Number of TF coils.
        a_tf_wp_with_insulation : float
            Area of winding pack with insulation [m²].
        a_tf_leg_outboard : float
            Outboard leg cross-sectional area [m²].
        rad_tf_coil_inboard_toroidal_half : float
            Half toroidal radius of inboard coil [m].
        r_tf_inboard_out : float
            Outer radius of inboard TF coil [m].
        tan_theta_coil : float
            Tangent of coil angle theta.
        r_tf_wp_inboard_outer : float
            Outer radius of inboard winding pack [m].
        dr_tf_plasma_case : float
            Radial thickness of plasma case [m].
        r_tf_wp_inboard_inner : float
            Inner radius of inboard winding pack [m].
        r_tf_inboard_in : float
            Inner radius of inboard TF coil [m].
        dx_tf_side_case_min : float
            Minimum lateral casing thickness [m].
        dr_tf_wp_with_insulation : float
            Radial thickness of winding pack with insulation [m].

        Returns
        -------
        tuple[float, float, float, float, float]
            Tuple containing:
            - a_tf_coil_inboard_case (float): Inboard case area [m²].
            - a_tf_coil_outboard_case (float): Outboard case area [m²].
            - a_tf_plasma_case (float): Front casing area [m²].
            - a_tf_coil_nose_case (float): Nose casing area [m²].
            - dx_tf_side_case_average (float): Average lateral casing thickness [m].
            - dx_tf_side_case_peak (float): Peak lateral casing thickness [m].
        """

        # Total area of inboard TF coil case [m²]
        a_tf_coil_inboard_case = (
            a_tf_inboard_total / n_tf_coils
        ) - a_tf_wp_with_insulation

        # Outboard leg cross-sectional area of surrounding case [m²]
        a_tf_coil_outboard_case = a_tf_leg_outboard - a_tf_wp_with_insulation

        # Front casing area [m²]
        if i_tf_case_geom == 0:
            # Circular front case
            a_tf_plasma_case = (
                rad_tf_coil_inboard_toroidal_half * r_tf_inboard_out**2
            ) - (tan_theta_coil * r_tf_wp_inboard_outer**2)
        else:
            # Straight front case [m²]
            a_tf_plasma_case = (
                (r_tf_wp_inboard_outer + dr_tf_plasma_case) ** 2
                - r_tf_wp_inboard_outer**2
            ) * tan_theta_coil

        # Nose casing area [m²]
        a_tf_coil_nose_case = (
            tan_theta_coil * r_tf_wp_inboard_inner**2
            - rad_tf_coil_inboard_toroidal_half * r_tf_inboard_in**2
        )

        # Report error if the casing area is negative
        if a_tf_coil_inboard_case <= 0.0e0 or a_tf_coil_outboard_case <= 0.0e0:
            logger.error(
                f"Winding pack cross-section problem... {a_tf_coil_inboard_case=} {a_tf_coil_outboard_case=}"
            )

        # Average lateral casing thickness [m]
        # --------------
        # Rectangular casing
        if i_tf_wp_geom == 0:
            dx_tf_side_case_average = (
                dx_tf_side_case_min + 0.5e0 * tan_theta_coil * dr_tf_wp_with_insulation
            )

        # Double rectangular WP
        elif i_tf_wp_geom == 1:
            dx_tf_side_case_average = (
                dx_tf_side_case_min + 0.25e0 * tan_theta_coil * dr_tf_wp_with_insulation
            )

        # Trapezoidal WP
        else:
            dx_tf_side_case_average = dx_tf_side_case_min

        # Peak lateral casing thickness [m]
        # --------------
        # Rectangular casing

        if i_tf_wp_geom == 0:
            dx_tf_side_case_peak = (
                dx_tf_side_case_min + tan_theta_coil * dr_tf_wp_with_insulation
            )
        # Double rectangular WP
        elif i_tf_wp_geom == 1:
            dx_tf_side_case_peak = (
                dx_tf_side_case_min + 0.5 * tan_theta_coil * dr_tf_wp_with_insulation
            )

        # Trapezoidal WP
        # Constant thickness so min = average
        else:
            dx_tf_side_case_peak = dx_tf_side_case_min

        return (
            a_tf_coil_inboard_case,
            a_tf_coil_outboard_case,
            a_tf_plasma_case,
            a_tf_coil_nose_case,
            dx_tf_side_case_average,
            dx_tf_side_case_peak,
        )

    def tf_cable_in_conduit_integer_turn_geometry(
        self,
        dr_tf_wp_with_insulation: float,
        dx_tf_wp_insulation: float,
        dx_tf_wp_insertion_gap: float,
        n_tf_wp_layers: int,
        dx_tf_wp_toroidal_min: float,
        n_tf_wp_pancakes: int,
        c_tf_coil: float,
        dx_tf_turn_steel: float,
        dx_tf_turn_insulation: float,
    ) -> tuple[
        float,  # radius_tf_turn_cable_space_corners
        float,  # dr_tf_turn
        float,  # dx_tf_turn
        float,  # a_tf_turn_cable_space_no_void
        float,  # a_tf_turn_steel
        float,  # a_tf_turn_insulation
        float,  # c_tf_turn
        float,  # n_tf_coil_turns
        float,  # t_conductor_radial
        float,  # t_conductor_toroidal
        float,  # t_conductor
        float,  # dr_tf_turn_cable_space
        float,  # dx_tf_turn_cable_space
        float,  # dx_tf_turn_cable_space_average
    ]:
        """Set the TF WP turn geometry for superconducting magnets using the number of turn rows in the radial direction.
        The turns can have any rectangular shape.

        This calculation checks if a turn can exist (positive cable space) and provides its dimensions, areas, and associated current.

        Parameters
        ----------
        dr_tf_wp_with_insulation : float
            Radial thickness of winding pack with insulation [m].
        dx_tf_wp_insulation : float
            Thickness of winding pack insulation [m].
        dx_tf_wp_insertion_gap : float
            Thickness of winding pack insertion gap [m].
        n_tf_wp_layers : int
            Number of winding pack layers (radial direction).
        dx_tf_wp_toroidal_min : float
            Minimum toroidal thickness of winding pack [m].
        n_tf_wp_pancakes : int
            Number of winding pack pancakes (toroidal direction).
        c_tf_coil : float
            Total TF coil current [A].
        dx_tf_turn_steel : float
            Thickness of turn steel [m].
        dx_tf_turn_insulation : float
            Thickness of turn insulation [m].

        Returns
        -------
        type
            tuple containing:
            - radius_tf_turn_cable_space_corners
            - dr_tf_turn
            - dx_tf_turn
            - a_tf_turn_cable_space_no_void
            - a_tf_turn_steel
            - a_tf_turn_insulation
            - c_tf_turn
            - n_tf_coil_turns
            - t_conductor_radial
            - t_conductor_toroidal
            - t_conductor
            - dr_tf_turn_cable_space
            - dx_tf_turn_cable_space
            - dx_tf_turn_cable_space_average
        """

        # Radius of rounded corners in the cable space [m]
        radius_tf_turn_cable_space_corners = dx_tf_turn_steel * 0.75e0

        # Radial turn dimension [m]
        dr_tf_turn = (
            dr_tf_wp_with_insulation
            - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
        ) / n_tf_wp_layers

        if dr_tf_turn <= (2.0e0 * dx_tf_turn_insulation + 2.0e0 * dx_tf_turn_steel):
            logger.error(
                "Negative cable space dimension; reduce conduit thicknesses or raise c_tf_turn. "
                f"{dr_tf_turn=} {dx_tf_turn_insulation=} {dx_tf_turn_steel=}"
            )

        # Toroidal turn dimension [m]
        dx_tf_turn = (
            dx_tf_wp_toroidal_min
            - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
        ) / n_tf_wp_pancakes

        if dx_tf_turn <= (2.0e0 * dx_tf_turn_insulation + 2.0e0 * dx_tf_turn_steel):
            logger.error(
                "Negative cable space dimension; reduce conduit thicknesses or raise c_tf_turn. "
                f"{dx_tf_turn=} {dx_tf_turn_insulation=} {dx_tf_turn_steel=}"
            )

        # Average turn dimension [m]
        tfcoil_variables.dx_tf_turn_general = np.sqrt(dr_tf_turn * dx_tf_turn)

        # Number of TF turns
        n_tf_coil_turns = np.double(n_tf_wp_layers * n_tf_wp_pancakes)

        # Current per turn [A/turn]
        c_tf_turn = c_tf_coil / n_tf_coil_turns

        # Radial and toroidal dimension of conductor [m]
        t_conductor_radial = dr_tf_turn - 2.0e0 * dx_tf_turn_insulation
        t_conductor_toroidal = dx_tf_turn - 2.0e0 * dx_tf_turn_insulation
        t_conductor = np.sqrt(t_conductor_radial * t_conductor_toroidal)

        # Dimension of square cable space inside conduit [m]
        dr_tf_turn_cable_space = t_conductor_radial - 2.0e0 * dx_tf_turn_steel
        dx_tf_turn_cable_space = t_conductor_toroidal - 2.0e0 * dx_tf_turn_steel
        dx_tf_turn_cable_space_average = np.sqrt(
            dr_tf_turn_cable_space * dx_tf_turn_cable_space
        )

        # Cross-sectional area of cable space per turn
        # taking account of rounded inside corners [m²]
        a_tf_turn_cable_space_no_void = (
            dr_tf_turn_cable_space * dx_tf_turn_cable_space
        ) - (4.0e0 - np.pi) * radius_tf_turn_cable_space_corners**2

        # Calculate the true effective cable space by taking away the cooling
        # channel and the extra void fraction
        superconducting_tf_coil_variables.a_tf_turn_cable_space_effective = (
            a_tf_turn_cable_space_no_void
            -
            # Coolant channel area
            (
                (np.pi / 4.0e0)
                * tfcoil_variables.dia_tf_turn_coolant_channel
                * tfcoil_variables.dia_tf_turn_coolant_channel
            )
            # Additional void area deduction
            - (
                a_tf_turn_cable_space_no_void
                * tfcoil_variables.f_a_tf_turn_cable_space_extra_void
            )
        )

        superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling = 1 - (
            superconducting_tf_coil_variables.a_tf_turn_cable_space_effective
            / a_tf_turn_cable_space_no_void
        )

        if a_tf_turn_cable_space_no_void <= 0.0e0:
            if (dr_tf_turn_cable_space < 0.0e0) or (dx_tf_turn_cable_space < 0.0e0):
                logger.error(
                    f"Negative cable space dimension. {a_tf_turn_cable_space_no_void=} "
                    f"{dr_tf_turn_cable_space=} {dx_tf_turn_cable_space=}"
                )
            else:
                logger.error(
                    "Cable space area problem; artificially set rounded corner radius to 0. "
                    f"{a_tf_turn_cable_space_no_void=} {dr_tf_turn_cable_space=}"
                    f" {dx_tf_turn_cable_space=}"
                )
                radius_tf_turn_cable_space_corners = 0.0e0
                a_tf_turn_cable_space_no_void = (
                    dr_tf_turn_cable_space * dx_tf_turn_cable_space
                )

        # Cross-sectional area of conduit jacket per turn [m²]
        a_tf_turn_steel = (
            t_conductor_radial * t_conductor_toroidal - a_tf_turn_cable_space_no_void
        )

        # Area of inter-turn insulation: single turn [m²]
        a_tf_turn_insulation = (
            dr_tf_turn * dx_tf_turn - a_tf_turn_steel - a_tf_turn_cable_space_no_void
        )
        return (
            radius_tf_turn_cable_space_corners,
            dr_tf_turn,
            dx_tf_turn,
            a_tf_turn_cable_space_no_void,
            a_tf_turn_steel,
            a_tf_turn_insulation,
            c_tf_turn,
            n_tf_coil_turns,
            t_conductor_radial,
            t_conductor_toroidal,
            t_conductor,
            dr_tf_turn_cable_space,
            dx_tf_turn_cable_space,
            dx_tf_turn_cable_space_average,
        )

        # -------------

    def tf_wp_currents(self):
        """
        Turn engineering turn currents/densities
        """
        tfcoil_variables.j_tf_wp = max(
            1.0e0,
            tfcoil_variables.c_tf_total
            / (
                tfcoil_variables.n_tf_coils
                * superconducting_tf_coil_variables.a_tf_wp_no_insulation
            ),
        )

    def tf_cable_in_conduit_averaged_turn_geometry(
        self,
        j_tf_wp,
        dx_tf_turn_steel,
        dx_tf_turn_insulation,
        i_tf_sc_mat,
        dx_tf_turn_general,
        c_tf_turn,
        i_dx_tf_turn_general_input,
        i_dx_tf_turn_cable_space_general_input,
        dx_tf_turn_cable_space_general,
        layer_ins,
        a_tf_wp_no_insulation,
        dia_tf_turn_coolant_channel,
        f_a_tf_turn_cable_space_extra_void,
    ):
        """subroutine straight from Python, see comments in tf_averaged_turn_geom_wrapper
        Setting the TF WP turn geometry for SC magnets from the number
        the current per turn.
        This calculation has two purposes, first to check if a turn can exist
        (positive cable space) and the second to provide its dimensions,
        areas and the (float) number of turns

        Parameters
        ----------
        j_tf_wp :

        dx_tf_turn_steel :

        dx_tf_turn_insulation :

        i_tf_sc_mat :

        dx_tf_turn_general :

        c_tf_turn :

        i_dx_tf_turn_general_input :

        i_dx_tf_turn_cable_space_general_input :

        dx_tf_turn_cable_space_general :

        layer_ins :

        a_tf_wp_no_insulation :

        dia_tf_turn_coolant_channel :

        f_a_tf_turn_cable_space_extra_void :

        """

        # Turn dimension is a an input
        if i_dx_tf_turn_general_input:
            # Turn area [m2]
            a_tf_turn = dx_tf_turn_general**2

            # Current per turn [A]
            c_tf_turn = a_tf_turn * j_tf_wp

        # Turn cable dimension is an input
        elif i_dx_tf_turn_cable_space_general_input:
            # Turn squared dimension [m]
            dx_tf_turn_general = dx_tf_turn_cable_space_general + 2.0e0 * (
                dx_tf_turn_insulation + dx_tf_turn_steel
            )

            # Turn area [m2]
            a_tf_turn = dx_tf_turn_general**2

            # Current per turn [A]
            c_tf_turn = a_tf_turn * j_tf_wp

        # Current per turn is an input
        else:
            # Turn area [m2]
            # Allow for additional inter-layer insulation MDK 13/11/18
            # Area of turn including conduit and inter-layer insulation
            a_tf_turn = c_tf_turn / j_tf_wp

            # Dimension of square cross-section of each turn including inter-turn insulation [m]
            dx_tf_turn_general = np.sqrt(a_tf_turn)

        # Square turn assumption
        dr_tf_turn = dx_tf_turn_general
        dx_tf_turn = dx_tf_turn_general

        # See derivation in the following document
        # k:\power plant physics and technology\process\hts\hts coil module for process.docx
        t_conductor = (
            -layer_ins + np.sqrt(layer_ins**2 + 4.0e00 * a_tf_turn)
        ) / 2 - 2.0e0 * dx_tf_turn_insulation

        # Total number of turns per TF coil (not required to be an integer)
        n_tf_coil_turns = a_tf_wp_no_insulation / a_tf_turn

        # Area of inter-turn insulation: single turn [m2]
        a_tf_turn_insulation = a_tf_turn - t_conductor**2

        # NOTE: Fortran has a_tf_turn_cable_space_no_void as an intent(out) variable that was outputting
        # into tfcoil_variables.a_tf_turn_cable_space_no_void. The local variable, however, appears to
        # initially hold the value of tfcoil_variables.a_tf_turn_cable_space_no_void despite not being
        # intent(in). I have replicated this behaviour in Python for now.
        a_tf_turn_cable_space_no_void = copy.copy(
            tfcoil_variables.a_tf_turn_cable_space_no_void
        )

        # ITER like turn structure
        if i_tf_sc_mat != 6:
            # Radius of rounded corners of cable space inside conduit [m]
            radius_tf_turn_cable_space_corners = dx_tf_turn_steel * 0.75e0

            # Dimension of square cable space inside conduit [m]
            dx_tf_turn_cable_space_average = t_conductor - 2.0e0 * dx_tf_turn_steel

            # Cross-sectional area of cable space per turn
            # taking account of rounded inside corners [m2]
            a_tf_turn_cable_space_no_void = (
                dx_tf_turn_cable_space_average**2
                - (4.0e0 - np.pi) * radius_tf_turn_cable_space_corners**2
            )

            # Calculate the true effective cable space by taking away the cooling
            # channel and the extra void fraction

            a_tf_turn_cable_space_effective = (
                a_tf_turn_cable_space_no_void
                -
                # Coolant channel area
                (
                    (np.pi / 4.0e0)
                    * dia_tf_turn_coolant_channel
                    * dia_tf_turn_coolant_channel
                )
                # Additional void area deduction
                - (a_tf_turn_cable_space_no_void * f_a_tf_turn_cable_space_extra_void)
            )

            f_a_tf_turn_cable_space_cooling = 1 - (
                a_tf_turn_cable_space_effective / a_tf_turn_cable_space_no_void
            )

            if a_tf_turn_cable_space_no_void <= 0.0e0:
                if t_conductor < 0.0e0:
                    logger.error(
                        f"Negative cable space dimension. {a_tf_turn_cable_space_no_void=} "
                        f"{dx_tf_turn_cable_space_average=}"
                    )
                else:
                    logger.error(
                        "Cable space area problem; artificially set rounded corner radius to 0. "
                        f"{a_tf_turn_cable_space_no_void=} {dx_tf_turn_cable_space_average=}"
                    )
                    radius_tf_turn_cable_space_corners = 0.0e0
                    a_tf_turn_cable_space_no_void = dx_tf_turn_cable_space_average**2

            # Cross-sectional area of conduit jacket per turn [m2]
            a_tf_turn_steel = t_conductor**2 - a_tf_turn_cable_space_no_void

        # REBCO turn structure
        elif i_tf_sc_mat == 6:
            # Diameter of circular cable space inside conduit [m]
            dx_tf_turn_cable_space_average = t_conductor - 2.0e0 * dx_tf_turn_steel

            # Cross-sectional area of conduit jacket per turn [m2]
            a_tf_turn_steel = t_conductor**2 - a_tf_turn_cable_space_no_void

        return (
            a_tf_turn_cable_space_no_void,
            a_tf_turn_steel,
            a_tf_turn_insulation,
            n_tf_coil_turns,
            dx_tf_turn_general,
            c_tf_turn,
            dx_tf_turn_general,
            dr_tf_turn,
            dx_tf_turn,
            t_conductor,
            radius_tf_turn_cable_space_corners,
            dx_tf_turn_cable_space_average,
            a_tf_turn_cable_space_effective,
            f_a_tf_turn_cable_space_cooling,
        )

    def superconducting_tf_coil_areas_and_masses(self):
        # Mass of case [kg]
        # ***

        # Mass of ground-wall insulation [kg]
        # (assumed to be same density/material as turn insulation)
        tfcoil_variables.m_tf_coil_wp_insulation = (
            tfcoil_variables.len_tf_coil
            * (
                superconducting_tf_coil_variables.a_tf_wp_with_insulation
                - superconducting_tf_coil_variables.a_tf_wp_no_insulation
            )
            * tfcoil_variables.den_tf_wp_turn_insulation
        )

        # The length of the vertical section is that of the first (inboard) segment
        # = height of TF coil inner edge + (2 * coil thickness)
        tfcoil_variables.cplen = (2.0e0 * build_variables.z_tf_inside_half) + (
            2.0e0 * build_variables.dr_tf_inboard
        )

        # The 2.2 factor is used as a scaling factor to fit
        # to the ITER-FDR value of 450 tonnes; see CCFE note T&M/PKNIGHT/PROCESS/026
        if physics_variables.itart == 1:
            # tfcoil_variables.len_tf_coil does not include inboard leg ('centrepost') length in TART
            tfcoil_variables.m_tf_coil_case = (
                2.2e0
                * tfcoil_variables.den_tf_coil_case
                * (
                    tfcoil_variables.cplen * tfcoil_variables.a_tf_coil_inboard_case
                    + tfcoil_variables.len_tf_coil
                    * tfcoil_variables.a_tf_coil_outboard_case
                )
            )
        else:
            tfcoil_variables.m_tf_coil_case = (
                2.2e0
                * tfcoil_variables.den_tf_coil_case
                * (
                    tfcoil_variables.cplen * tfcoil_variables.a_tf_coil_inboard_case
                    + (tfcoil_variables.len_tf_coil - tfcoil_variables.cplen)
                    * tfcoil_variables.a_tf_coil_outboard_case
                )
            )

        # ***

        # Masses of conductor constituents
        # ---------------------------------
        # Superconductor mass [kg]
        # Includes space allowance for central helium channel, area tfcoil_variables.a_tf_wp_coolant_channels
        tfcoil_variables.m_tf_coil_superconductor = (
            tfcoil_variables.len_tf_coil
            * tfcoil_variables.n_tf_coil_turns
            * tfcoil_variables.a_tf_turn_cable_space_no_void
            * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
            * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_copper)
            - tfcoil_variables.len_tf_coil * tfcoil_variables.a_tf_wp_coolant_channels
        ) * tfcoil_variables.dcond[tfcoil_variables.i_tf_sc_mat - 1]

        # Copper mass [kg]
        tfcoil_variables.m_tf_coil_copper = (
            tfcoil_variables.len_tf_coil
            * tfcoil_variables.n_tf_coil_turns
            * tfcoil_variables.a_tf_turn_cable_space_no_void
            * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
            * tfcoil_variables.f_a_tf_turn_cable_copper
            - tfcoil_variables.len_tf_coil * tfcoil_variables.a_tf_wp_coolant_channels
        ) * constants.den_copper
        if tfcoil_variables.m_tf_coil_copper <= 0.0e0:
            tfcoil_variables.m_tf_coil_copper = 0.0e0

        # Steel conduit (sheath) mass [kg]
        tfcoil_variables.m_tf_wp_steel_conduit = (
            tfcoil_variables.len_tf_coil
            * tfcoil_variables.n_tf_coil_turns
            * tfcoil_variables.a_tf_turn_steel
            * fwbs_variables.den_steel
        )

        # Conduit insulation mass [kg]
        # (tfcoil_variables.a_tf_coil_wp_turn_insulation already contains tfcoil_variables.n_tf_coil_turns)
        tfcoil_variables.m_tf_coil_wp_turn_insulation = (
            tfcoil_variables.len_tf_coil
            * tfcoil_variables.a_tf_coil_wp_turn_insulation
            * tfcoil_variables.den_tf_wp_turn_insulation
        )

        # Total conductor mass [kg]
        tfcoil_variables.m_tf_coil_conductor = (
            tfcoil_variables.m_tf_coil_superconductor
            + tfcoil_variables.m_tf_coil_copper
            + tfcoil_variables.m_tf_wp_steel_conduit
            + tfcoil_variables.m_tf_coil_wp_turn_insulation
        )
        # ---------------------------------

        # Total TF coil mass [kg] (all coils)
        tfcoil_variables.m_tf_coils_total = (
            tfcoil_variables.m_tf_coil_case
            + tfcoil_variables.m_tf_coil_conductor
            + tfcoil_variables.m_tf_coil_wp_insulation
        ) * tfcoil_variables.n_tf_coils

        # If spherical tokamak, distribute between centrepost and outboard legs
        # (in this case, total TF coil length = inboard `cplen` + outboard `len_tf_coil`)
        if physics_variables.itart == 1:
            tfleng_sph = tfcoil_variables.cplen + tfcoil_variables.len_tf_coil
            tfcoil_variables.whtcp = tfcoil_variables.m_tf_coils_total * (
                tfcoil_variables.cplen / tfleng_sph
            )
            tfcoil_variables.whttflgs = tfcoil_variables.m_tf_coils_total * (
                tfcoil_variables.len_tf_coil / tfleng_sph
            )

outfile = constants.NOUT instance-attribute

run(output)

Routine to call the superconductor module for the TF coils

Parameters:

Name Type Description Default
output bool
required
Source code in process/models/tfcoil/superconducting.py
 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
def run(self, output: bool):
    """Routine to call the superconductor module for the TF coils

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

    """
    self.iprint = 0

    # Set up TF values share by all coil types
    self.run_base_tf()

    self.sc_tf_internal_geom(
        tfcoil_variables.i_tf_wp_geom,
        tfcoil_variables.i_tf_case_geom,
        tfcoil_variables.i_tf_turns_integer,
    )

    tfcoil_variables.ind_tf_coil = self.tf_coil_self_inductance(
        dr_tf_inboard=build_variables.dr_tf_inboard,
        r_tf_arc=tfcoil_variables.r_tf_arc,
        z_tf_arc=tfcoil_variables.z_tf_arc,
        itart=physics_variables.itart,
        i_tf_shape=tfcoil_variables.i_tf_shape,
        z_tf_inside_half=build_variables.z_tf_inside_half,
        dr_tf_outboard=build_variables.dr_tf_outboard,
        r_tf_outboard_mid=build_variables.r_tf_outboard_mid,
        r_tf_inboard_mid=build_variables.r_tf_inboard_mid,
    )

    (
        superconducting_tf_coil_variables.e_tf_magnetic_stored_total,
        tfcoil_variables.e_tf_magnetic_stored_total_gj,
        tfcoil_variables.e_tf_coil_magnetic_stored,
    ) = self.tf_stored_magnetic_energy(
        ind_tf_coil=tfcoil_variables.ind_tf_coil,
        c_tf_total=tfcoil_variables.c_tf_total,
        n_tf_coils=tfcoil_variables.n_tf_coils,
    )

    (
        tfcoil_variables.cforce,
        tfcoil_variables.vforce,
        tfcoil_variables.vforce_outboard,
        superconducting_tf_coil_variables.vforce_inboard_tot,
        tfcoil_variables.f_vforce_inboard,
    ) = self.tf_field_and_force(
        i_tf_sup=tfcoil_variables.i_tf_sup,
        r_tf_wp_inboard_outer=superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
        r_tf_wp_inboard_inner=superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
        r_tf_outboard_in=superconducting_tf_coil_variables.r_tf_outboard_in,
        dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
        dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
        b_tf_inboard_peak_symmetric=tfcoil_variables.b_tf_inboard_peak_symmetric,
        c_tf_total=tfcoil_variables.c_tf_total,
        n_tf_coils=tfcoil_variables.n_tf_coils,
        dr_tf_plasma_case=tfcoil_variables.dr_tf_plasma_case,
        rmajor=physics_variables.rmajor,
        b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis,
        r_cp_top=build_variables.r_cp_top,
        itart=physics_variables.itart,
        i_cp_joints=tfcoil_variables.i_cp_joints,
        f_vforce_inboard=tfcoil_variables.f_vforce_inboard,
    )

    # Calculate TF coil areas and masses
    self.generic_tf_coil_area_and_masses()
    self.superconducting_tf_coil_areas_and_masses()

    # Do stress calculations (writes the stress output)
    if output:
        tfcoil_variables.n_rad_per_layer = 500

    try:
        (
            sig_tf_r_max,
            sig_tf_t_max,
            sig_tf_z_max,
            sig_tf_vmises_max,
            s_shear_tf_peak,
            deflect,
            eyoung_axial,
            eyoung_trans,
            eyoung_wp_axial,
            eyoung_wp_trans,
            poisson_wp_trans,
            radial_array,
            s_shear_cea_tf_cond,
            poisson_wp_axial,
            sig_tf_r,
            sig_tf_smeared_r,
            sig_tf_smeared_t,
            sig_tf_smeared_z,
            sig_tf_t,
            s_shear_tf,
            sig_tf_vmises,
            sig_tf_z,
            str_tf_r,
            str_tf_t,
            str_tf_z,
            n_radial_array,
            n_tf_bucking,
            tfcoil_variables.sig_tf_wp,
            sig_tf_case,
            sig_tf_cs_bucked,
            str_wp,
            casestr,
            insstrain,
            sig_tf_wp_av_z,
        ) = self.stresscl(
            int(tfcoil_variables.n_tf_stress_layers),
            int(tfcoil_variables.n_rad_per_layer),
            int(tfcoil_variables.n_tf_wp_stress_layers),
            int(tfcoil_variables.i_tf_bucking),
            float(build_variables.r_tf_inboard_in),
            build_variables.dr_bore,
            build_variables.z_tf_inside_half,
            pfcoil_variables.f_z_cs_tf_internal,
            build_variables.dr_cs,
            build_variables.i_tf_inside_cs,
            build_variables.dr_tf_inboard,
            build_variables.dr_cs_tf_gap,
            pfcoil_variables.i_pf_conductor,
            pfcoil_variables.j_cs_flat_top_end,
            pfcoil_variables.j_cs_pulse_start,
            pfcoil_variables.c_pf_coil_turn_peak_input,
            pfcoil_variables.n_pf_coils_in_group,
            pfcoil_variables.f_dr_dz_cs_turn,
            pfcoil_variables.radius_cs_turn_corners,
            pfcoil_variables.f_a_cs_turn_steel,
            tfcoil_variables.eyoung_steel,
            tfcoil_variables.poisson_steel,
            tfcoil_variables.eyoung_cond_axial,
            tfcoil_variables.poisson_cond_axial,
            tfcoil_variables.eyoung_cond_trans,
            tfcoil_variables.poisson_cond_trans,
            tfcoil_variables.eyoung_ins,
            tfcoil_variables.poisson_ins,
            tfcoil_variables.dx_tf_turn_insulation,
            tfcoil_variables.eyoung_copper,
            tfcoil_variables.poisson_copper,
            tfcoil_variables.i_tf_sup,
            tfcoil_variables.eyoung_res_tf_buck,
            superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
            superconducting_tf_coil_variables.tan_theta_coil,
            superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half,
            superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
            superconducting_tf_coil_variables.a_tf_coil_inboard_steel,
            superconducting_tf_coil_variables.a_tf_plasma_case,
            superconducting_tf_coil_variables.a_tf_coil_nose_case,
            tfcoil_variables.dx_tf_wp_insertion_gap,
            tfcoil_variables.dx_tf_wp_insulation,
            tfcoil_variables.n_tf_coil_turns,
            int(tfcoil_variables.i_tf_turns_integer),
            superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
            superconducting_tf_coil_variables.dr_tf_turn_cable_space,
            tfcoil_variables.dia_tf_turn_coolant_channel,
            tfcoil_variables.f_a_tf_turn_cable_copper,
            tfcoil_variables.dx_tf_turn_steel,
            superconducting_tf_coil_variables.dx_tf_side_case_average,
            superconducting_tf_coil_variables.dx_tf_wp_toroidal_average,
            superconducting_tf_coil_variables.a_tf_coil_inboard_insulation,
            tfcoil_variables.a_tf_wp_steel,
            tfcoil_variables.a_tf_wp_conductor,
            superconducting_tf_coil_variables.a_tf_wp_with_insulation,
            tfcoil_variables.eyoung_al,
            tfcoil_variables.poisson_al,
            tfcoil_variables.fcoolcp,
            tfcoil_variables.n_tf_graded_layers,
            tfcoil_variables.c_tf_total,
            tfcoil_variables.dr_tf_plasma_case,
            tfcoil_variables.i_tf_stress_model,
            superconducting_tf_coil_variables.vforce_inboard_tot,
            tfcoil_variables.i_tf_tresca,
            tfcoil_variables.a_tf_coil_inboard_case,
            tfcoil_variables.vforce,
            tfcoil_variables.a_tf_turn_steel,
        )

        tfcoil_variables.sig_tf_case = (
            tfcoil_variables.sig_tf_case
            if tfcoil_variables.sig_tf_case is None
            else sig_tf_case
        )

        tfcoil_variables.sig_tf_cs_bucked = (
            tfcoil_variables.sig_tf_cs_bucked
            if tfcoil_variables.sig_tf_cs_bucked is None
            else sig_tf_cs_bucked
        )

        tfcoil_variables.str_wp = (
            tfcoil_variables.str_wp if tfcoil_variables.str_wp is None else str_wp
        )

        tfcoil_variables.casestr = (
            tfcoil_variables.casestr if tfcoil_variables.casestr is None else casestr
        )

        tfcoil_variables.insstrain = (
            tfcoil_variables.insstrain
            if tfcoil_variables.insstrain is None
            else insstrain
        )

        if output:
            self.out_stress(
                sig_tf_r_max,
                sig_tf_t_max,
                sig_tf_z_max,
                sig_tf_vmises_max,
                s_shear_tf_peak,
                deflect,
                eyoung_axial,
                eyoung_trans,
                eyoung_wp_axial,
                eyoung_wp_trans,
                poisson_wp_trans,
                radial_array,
                s_shear_cea_tf_cond,
                poisson_wp_axial,
                sig_tf_r,
                sig_tf_smeared_r,
                sig_tf_smeared_t,
                sig_tf_smeared_z,
                sig_tf_t,
                s_shear_tf,
                sig_tf_vmises,
                sig_tf_z,
                str_tf_r,
                str_tf_t,
                str_tf_z,
                n_radial_array,
                n_tf_bucking,
                sig_tf_wp_av_z,
            )
    except ValueError as e:
        if e.args[1] == 245 and e.args[2] == 0:
            logger.warning(
                "Invalid stress model (r_tf_inboard = 0), stress constraint switched off"
            )
            tfcoil_variables.sig_tf_case = 0.0e0
            tfcoil_variables.sig_tf_wp = 0.0e0

    self.vv_stress_on_quench()

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

    # Peak inboard toroidal field including ripple
    tfcoil_variables.b_tf_inboard_peak_with_ripple = self.peak_b_tf_inboard_with_ripple(
        n_tf_coils=tfcoil_variables.n_tf_coils,
        dx_tf_wp_primary_toroidal=tfcoil_variables.dx_tf_wp_primary_toroidal,
        dr_tf_wp_no_insulation=superconducting_tf_coil_variables.dr_tf_wp_no_insulation,
        r_tf_wp_inboard_centre=superconducting_tf_coil_variables.r_tf_wp_inboard_centre,
        b_tf_inboard_peak_symmetric=tfcoil_variables.b_tf_inboard_peak_symmetric,
    )
    # ======================================================

    # Cross-sectional area per turn
    a_tf_turn = tfcoil_variables.c_tf_total / (
        tfcoil_variables.j_tf_wp
        * tfcoil_variables.n_tf_coils
        * tfcoil_variables.n_tf_coil_turns
    )

    if tfcoil_variables.i_tf_sc_mat == 6:
        (
            tfcoil_variables.j_tf_wp_critical,
            tfcoil_variables.temp_tf_superconductor_margin,
        ) = self.supercon_croco(
            a_tf_turn,
            tfcoil_variables.b_tf_inboard_peak_with_ripple,
            tfcoil_variables.c_tf_turn,
            tfcoil_variables.tftmp,
            output=output,
        )

        tfcoil_variables.v_tf_coil_dump_quench_kv = (
            self.croco_voltage() / 1.0e3
        )  # TFC Quench voltage in kV

    else:
        (
            tfcoil_variables.j_tf_wp_critical,
            superconducting_tf_coil_variables.j_tf_superconductor_critical,
            superconducting_tf_coil_variables.f_c_tf_turn_operating_critical,
            superconducting_tf_coil_variables.j_tf_superconductor,
            superconducting_tf_coil_variables.j_tf_coil_turn,
            superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
            superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
            superconducting_tf_coil_variables.c_tf_turn_cables_critical,
        ) = self.tf_cable_in_conduit_superconductor_properties(
            a_tf_turn_cable_space=tfcoil_variables.a_tf_turn_cable_space_no_void,
            a_tf_turn=a_tf_turn,
            a_tf_turn_cable_space_effective=superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
            f_a_tf_turn_cable_space_cooling=superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
            b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
            f_a_tf_turn_cable_copper=tfcoil_variables.f_a_tf_turn_cable_copper,
            c_tf_turn=tfcoil_variables.c_tf_turn,
            j_tf_wp=tfcoil_variables.j_tf_wp,
            i_tf_superconductor=tfcoil_variables.i_tf_sc_mat,
            f_strain_scale=tfcoil_variables.fhts,
            temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
            bcritsc=tfcoil_variables.bcritsc,
            tcritsc=tfcoil_variables.tcritsc,
        )

    if tfcoil_variables.i_str_wp == 0:
        strain = tfcoil_variables.str_tf_con_res
    else:
        strain = tfcoil_variables.str_wp

    tfcoil_variables.temp_tf_superconductor_margin = self.calculate_superconductor_temperature_margin(
        i_tf_superconductor=tfcoil_variables.i_tf_sc_mat,
        j_superconductor=superconducting_tf_coil_variables.j_tf_superconductor,
        b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
        strain=strain,
        bc20m=superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
        tc0m=superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
        c0=1.0e10,
        temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
    )

    # Do current density protection calculation
    # Only setup for Nb3Sn at present.
    if tfcoil_variables.i_tf_sc_mat not in {1, 4, 5}:
        logger.warning(
            "Calculating current density protection limit for Nb3Sn TF coil (LTS windings only)"
        )
        # Find the current density limited by the protection limit
        # At present only valid for LTS windings (Nb3Sn properties assumed)
    tfcoil_variables.j_tf_wp_quench_heat_max, v_tf_coil_dump_quench = (
        self.quench_heat_protection_current_density(
            c_tf_turn=tfcoil_variables.c_tf_turn,
            e_tf_coil_magnetic_stored=tfcoil_variables.e_tf_coil_magnetic_stored,
            a_tf_turn_cable_space=tfcoil_variables.a_tf_turn_cable_space_no_void,
            a_tf_turn=a_tf_turn,
            t_tf_quench_dump=tfcoil_variables.t_tf_superconductor_quench,
            f_a_tf_turn_cable_space_conductor=1.0e0
            - superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
            f_a_tf_turn_cable_copper=tfcoil_variables.f_a_tf_turn_cable_copper,
            temp_tf_coolant_peak_field=tfcoil_variables.tftmp,
            temp_tf_conductor_quench_max=tfcoil_variables.temp_tf_conductor_quench_max,
            b_tf_inboard_peak=tfcoil_variables.b_tf_inboard_peak_with_ripple,
            cu_rrr=tfcoil_variables.rrr_tf_cu,
            t_tf_quench_detection=tfcoil_variables.t_tf_quench_detection,
            nflutfmax=constraint_variables.nflutfmax,
        )
    )

    tfcoil_variables.v_tf_coil_dump_quench_kv = (
        v_tf_coil_dump_quench / 1.0e3
    )  # TFC Quench voltage in kV

    if output:
        self.outtf()

croco_voltage()

Source code in process/models/tfcoil/superconducting.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
def croco_voltage(self) -> float:
    if tfcoil_variables.quench_model == "linear":
        superconducting_tf_coil_variables.time2 = (
            tfcoil_variables.t_tf_superconductor_quench
        )
        croco_voltage = (
            2.0e0
            / superconducting_tf_coil_variables.time2
            * (
                superconducting_tf_coil_variables.e_tf_magnetic_stored_total
                / tfcoil_variables.n_tf_coils
            )
            / tfcoil_variables.c_tf_turn
        )
    elif tfcoil_variables.quench_model == "exponential":
        superconducting_tf_coil_variables.tau2 = (
            tfcoil_variables.t_tf_superconductor_quench
        )
        croco_voltage = (
            2.0e0
            / superconducting_tf_coil_variables.tau2
            * (
                superconducting_tf_coil_variables.e_tf_magnetic_stored_total
                / tfcoil_variables.n_tf_coils
            )
            / tfcoil_variables.c_tf_turn
        )
    else:
        return 0.0

    return croco_voltage

supercon_croco(a_tf_turn, b_tf_inboard_peak_symmetric, iop, thelium, output)

TF superconducting CroCo conductor using REBCO tape

Parameters:

Name Type Description Default
a_tf_turn
required
b_tf_inboard_peak_symmetric

Peak field at conductor (T)

required
iop

Operating current per turn (A)

required
thelium

He temperature at peak field point (K)

required
output bool
required
Source code in process/models/tfcoil/superconducting.py
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
def supercon_croco(
    self, a_tf_turn, b_tf_inboard_peak_symmetric, iop, thelium, output: bool
):
    """TF superconducting CroCo conductor using REBCO tape

    Parameters
    ----------
    a_tf_turn :

    b_tf_inboard_peak_symmetric :
        Peak field at conductor (T)
    iop :
        Operating current per turn (A)
    thelium :
        He temperature at peak field point (K)
    output:

    """

    j_crit_sc: float = 0.0
    #  Find critical current density in superconducting cable, j_crit_cable
    j_crit_sc, _ = superconductors.jcrit_rebco(thelium, b_tf_inboard_peak_symmetric)
    # tfcoil_variables.a_tf_turn_cable_space_no_void : Cable space - inside area (m2)
    # Set new rebco_variables.dia_croco_strand
    # allowing for scaling of rebco_variables.dia_croco_strand
    rebco_variables.dia_croco_strand = (
        tfcoil_variables.t_conductor / 3.0e0
        - tfcoil_variables.dx_tf_turn_steel * (2.0e0 / 3.0e0)
    )
    superconducting_tf_coil_variables.conductor_acs = (
        9.0e0 / 4.0e0 * np.pi * rebco_variables.dia_croco_strand**2
    )
    tfcoil_variables.a_tf_turn_cable_space_no_void = (
        superconducting_tf_coil_variables.conductor_acs
    )
    superconducting_tf_coil_variables.conductor_area = (
        tfcoil_variables.t_conductor**2
    )  # does this not assume it's a sqaure???

    superconducting_tf_coil_variables.conductor_jacket_area = (
        superconducting_tf_coil_variables.conductor_area
        - superconducting_tf_coil_variables.conductor_acs
    )
    tfcoil_variables.a_tf_turn_steel = (
        superconducting_tf_coil_variables.conductor_jacket_area
    )

    superconducting_tf_coil_variables.conductor_jacket_fraction = (
        superconducting_tf_coil_variables.conductor_jacket_area
        / superconducting_tf_coil_variables.conductor_area
    )
    (
        superconducting_tf_coil_variables.croco_strand_area,
        superconducting_tf_coil_variables.croco_strand_critical_current,
        superconducting_tf_coil_variables.conductor_copper_area,
        superconducting_tf_coil_variables.conductor_copper_fraction,
        superconducting_tf_coil_variables.conductor_copper_bar_area,
        superconducting_tf_coil_variables.conductor_hastelloy_area,
        superconducting_tf_coil_variables.conductor_hastelloy_fraction,
        superconducting_tf_coil_variables.conductor_helium_area,
        superconducting_tf_coil_variables.conductor_helium_fraction,
        superconducting_tf_coil_variables.conductor_solder_area,
        superconducting_tf_coil_variables.conductor_solder_fraction,
        superconducting_tf_coil_variables.conductor_rebco_area,
        superconducting_tf_coil_variables.conductor_rebco_fraction,
        superconducting_tf_coil_variables.conductor_critical_current,
    ) = superconductors.croco(
        j_crit_sc,
        superconducting_tf_coil_variables.conductor_area,
        rebco_variables.dia_croco_strand,
        rebco_variables.dx_croco_strand_copper,
    )

    rebco_variables.coppera_m2 = (
        iop / superconducting_tf_coil_variables.conductor_copper_area
    )

    icrit = superconducting_tf_coil_variables.conductor_critical_current
    j_crit_cable = (
        superconducting_tf_coil_variables.croco_strand_critical_current
        / superconducting_tf_coil_variables.croco_strand_area
    )

    # Critical current density in winding pack
    # a_tf_turn : Area per turn (i.e. entire jacketed conductor with insulation) (m2)
    j_tf_wp_critical = icrit / a_tf_turn
    #  Ratio of operating / critical current
    iooic = iop / icrit
    #  Operating current density
    jwdgop = iop / a_tf_turn
    #  Actual current density in superconductor,
    # which should be equal to jcrit(thelium+tmarg)

    #  when we have found the desired value of tmarg
    jsc = iooic * j_crit_sc

    # Temperature margin
    current_sharing_t = superconductors.current_sharing_rebco(
        b_tf_inboard_peak_symmetric, jsc
    )
    tmarg = current_sharing_t - thelium
    tfcoil_variables.temp_margin = (
        tmarg  # Only used in the availabilty routine - see comment to Issue #526
    )

    if output:  # Output ----------------------------------
        total = (
            superconducting_tf_coil_variables.conductor_copper_area
            + superconducting_tf_coil_variables.conductor_hastelloy_area
            + superconducting_tf_coil_variables.conductor_solder_area
            + superconducting_tf_coil_variables.conductor_jacket_area
            + superconducting_tf_coil_variables.conductor_helium_area
            + superconducting_tf_coil_variables.conductor_rebco_area
        )

        if tfcoil_variables.temp_margin <= 0.0e0:
            logger.error(
                f"""Negative TFC temperature margin
            temp_margin: {tfcoil_variables.temp_margin}
            b_tf_inboard_peak_symmetric: {b_tf_inboard_peak_symmetric}"""
            )

        po.oheadr(self.outfile, "Superconducting TF Coils")
        po.ovarin(self.outfile, "Superconductor switch", "(isumat)", 6)
        po.ocmmnt(
            self.outfile, "Superconductor used: REBCO HTS tape in CroCo strand"
        )

        po.ovarre(
            self.outfile,
            "Thickness of REBCO layer in tape (m)",
            "(dx_hts_tape_rebco)",
            rebco_variables.dx_hts_tape_rebco,
        )
        po.ovarre(
            self.outfile,
            "Thickness of copper layer in tape (m)",
            "(dx_hts_tape_copper)",
            rebco_variables.dx_hts_tape_copper,
        )
        po.ovarre(
            self.outfile,
            "Thickness of Hastelloy layer in tape (m) ",
            "(dx_hts_tape_hastelloy)",
            rebco_variables.dx_hts_tape_hastelloy,
        )

        po.ovarre(
            self.outfile,
            "Mean width of tape (m)",
            "(dr_hts_tape)",
            rebco_variables.dr_hts_tape,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Diameter of a CroCo strand (m) ",
            "(dia_croco_strand)",
            rebco_variables.dia_croco_strand,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Inner diameter of CroCo copper tube (m) ",
            "(dia_croco_strand_tape_region)",
            rebco_variables.dia_croco_strand_tape_region,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Thickness of of o copper tube (m) ",
            "(dx_croco_strand_copper)",
            rebco_variables.dx_croco_strand_copper,
        )

        po.ovarre(
            self.outfile,
            "Thickness of each HTS tape ",
            "(dx_hts_tape_total)",
            rebco_variables.dx_hts_tape_total,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Thickness of stack of rebco_variables.n_croco_strand_hts_tapes (m) ",
            "(dx_croco_strand_tape_stack)",
            rebco_variables.dx_croco_strand_tape_stack,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Number of rebco_variables.n_croco_strand_hts_tapes in strand",
            "(n_croco_strand_hts_tapes)",
            rebco_variables.n_croco_strand_hts_tapes,
            "OP ",
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Area of REBCO in strand (m2)",
            "(a_croco_strand_rebco)",
            rebco_variables.a_croco_strand_rebco,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Area of copper in strand (m2)",
            "(a_croco_strand_copper_total)",
            rebco_variables.a_croco_strand_copper_total,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Area of hastelloy substrate in strand (m2) ",
            "(a_croco_strand_hastelloy)",
            rebco_variables.a_croco_strand_hastelloy,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Area of solder in strand (m2)  ",
            "(a_croco_strand_solder)",
            rebco_variables.a_croco_strand_solder,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total: area of CroCo strand (m2)  ",
            "(croco_strand_area)",
            superconducting_tf_coil_variables.croco_strand_area,
            "OP ",
        )
        if (
            abs(
                superconducting_tf_coil_variables.croco_strand_area
                - (
                    rebco_variables.a_croco_strand_rebco
                    + rebco_variables.a_croco_strand_copper_total
                    + rebco_variables.a_croco_strand_hastelloy
                    + rebco_variables.a_croco_strand_solder
                )
            )
            > 1e-6
        ):
            po.ocmmnt(self.outfile, "ERROR: Areas in CroCo strand do not add up")
            logger.error("Areas in CroCo strand do not add up - see OUT.DAT")

        po.oblnkl(self.outfile)
        po.ocmmnt(self.outfile, "Cable information")
        po.ovarin(
            self.outfile,
            "Number of CroCo strands in the cable (fixed) ",
            "",
            6,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total area of cable space (m2)",
            "(a_tf_turn_cable_space_no_void)",
            tfcoil_variables.a_tf_turn_cable_space_no_void,
            "OP ",
        )

        po.oblnkl(self.outfile)
        po.ocmmnt(
            self.outfile,
            "Conductor information (includes jacket, not including insulation)",
        )
        po.ovarre(
            self.outfile,
            "Width of square conductor (cable + steel jacket) (m)",
            "(t_conductor)",
            tfcoil_variables.t_conductor,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Area of conductor (m2)",
            "(area)",
            superconducting_tf_coil_variables.conductor_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "REBCO area of conductor (mm2)",
            "(a_croco_strand_rebco)",
            superconducting_tf_coil_variables.conductor_rebco_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Area of central copper bar (mm2)",
            "(copper_bar_area)",
            superconducting_tf_coil_variables.conductor_copper_bar_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Total copper area of conductor, total (mm2)",
            "(a_croco_strand_copper_total)",
            superconducting_tf_coil_variables.conductor_copper_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Hastelloy area of conductor (mm2)",
            "(a_croco_strand_hastelloy)",
            superconducting_tf_coil_variables.conductor_hastelloy_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Solder area of conductor (mm2)",
            "(a_croco_strand_solder)",
            superconducting_tf_coil_variables.conductor_solder_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Jacket area of conductor (mm2)",
            "(jacket_area)",
            superconducting_tf_coil_variables.conductor_jacket_area,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Helium area of conductor (mm2)",
            "(helium_area)",
            superconducting_tf_coil_variables.conductor_helium_area,
            "OP ",
        )
        if abs(total - superconducting_tf_coil_variables.conductor_area) > 1e-8:
            po.ovarre(
                self.outfile,
                "ERROR: conductor areas do not add up:",
                "(total)",
                total,
                "OP ",
            )
            logger.error(f"conductor areas do not add up. total: {total}")

        po.ovarre(
            self.outfile,
            "Critical current of CroCo strand (A)",
            "(croco_strand_critical_current)",
            superconducting_tf_coil_variables.croco_strand_critical_current,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Critical current of conductor (A) ",
            "(conductor_critical_current)",
            superconducting_tf_coil_variables.conductor_critical_current,
            "OP ",
        )

        if global_variables.run_tests == 1:
            po.oblnkl(self.outfile)
            po.ocmmnt(
                self.outfile,
                "PROCESS TF Coil peak field fit. Values for t, z and y:",
            )
            po.oblnkl(self.outfile)
            po.ovarre(
                self.outfile,
                "Dimensionless winding pack width",
                "(tf_fit_t)",
                superconducting_tf_coil_variables.tf_fit_t,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Dimensionless winding pack radial thickness",
                "(tf_fit_z)",
                superconducting_tf_coil_variables.tf_fit_z,
                "OP ",
            )
            po.ovarre(
                self.outfile,
                "Ratio of actual peak field to nominal axisymmetric peak field",
                "(f_b_tf_inboard_peak_ripple_symmetric)",
                superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric,
                "OP ",
            )

        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Helium temperature at peak field (= superconductor temperature) (K)",
            "(thelium)",
            thelium,
        )
        po.ovarre(
            self.outfile,
            "Critical current density in superconductor (A/m2)",
            "(j_crit_sc)",
            j_crit_sc,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Critical current density in cable (A/m2)",
            "(j_crit_cable)",
            j_crit_cable,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Critical current density in winding pack (A/m2)",
            "(j_tf_wp_critical)",
            j_tf_wp_critical,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Actual current density in winding pack (A/m2)",
            "(jwdgop)",
            jwdgop,
            "OP ",
        )

        po.ovarre(
            self.outfile,
            "Minimum allowed temperature margin in superconductor (K)",
            "(temp_tf_superconductor_margin_min)",
            tfcoil_variables.temp_tf_superconductor_margin_min,
        )

        po.ovarre(
            self.outfile,
            "Actual temperature margin in superconductor (K)",
            "(tmarg)",
            tmarg,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Current sharing temperature (K)",
            "(current_sharing_t)",
            current_sharing_t,
            "OP ",
        )
        po.ovarre(self.outfile, "Critical current (A)", "(icrit)", icrit, "OP ")
        po.ovarre(
            self.outfile,
            "Actual current (A)",
            "(c_tf_turn)",
            tfcoil_variables.c_tf_turn,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Actual current / critical current",
            "(iooic)",
            iooic,
            "OP ",
        )

    return j_tf_wp_critical, tmarg

tf_cable_in_conduit_superconductor_properties(a_tf_turn_cable_space, a_tf_turn, a_tf_turn_cable_space_effective, f_a_tf_turn_cable_space_cooling, b_tf_inboard_peak, f_a_tf_turn_cable_copper, c_tf_turn, j_tf_wp, i_tf_superconductor, f_strain_scale, temp_tf_coolant_peak_field, bcritsc, tcritsc)

Calculates the properties of the TF superconducting conductor.

Parameters:

Name Type Description Default
a_tf_turn_cable_space float

Cable space - inside area (m²).

required
a_tf_turn float

Area per turn (i.e. entire jacketed conductor) (m²).

required
a_tf_turn_cable_space_effective float

Effective cable space area per turn (m²).

required
f_a_tf_turn_cable_space_cooling float

Fraction of cable space used for cooling.

required
b_tf_inboard_peak float

Peak field at conductor (T).

required
f_a_tf_turn_cable_copper float

Fraction of conductor that is copper.

required
c_tf_turn float

Operating current per turn (A).

required
j_tf_wp float

Actual winding pack current density (A/m²).

required
i_tf_superconductor int

Switch for conductor type: - 1: ITER Nb3Sn, standard parameters - 2: Bi-2212 High Temperature Superconductor - 3: NbTi - 4: ITER Nb3Sn, user-defined parameters - 5: WST Nb3Sn parameterisation - 7: Durham Ginzburg-Landau Nb-Ti parameterisation - 8: Durham Ginzburg-Landau critical surface model for REBCO - 9: Hazelton experimental data + Zhai conceptual model for REBCO

required
f_strain_scale float

Adjustment factor (<= 1) to account for strain, radiation damage, fatigue or AC losses.

required
temp_tf_coolant_peak_field float

He temperature at peak field point (K).

required
bcritsc float

Critical field at zero temperature and strain (T) (used only if i_tf_superconductor=4).

required
tcritsc float

Critical temperature at zero field and strain (K) (used only if i_tf_superconductor=4).

required

Returns:

Type Description
type

tuple (float, float, float, float, float, float, float, float, float) - j_tf_wp_critical (float): Critical winding pack current density (A/m²). - j_superconductor_critical (float): Critical current density in superconductor (A/m²). - f_c_tf_turn_operating_critical (float): Ratio of operating / critical current. - j_superconductor_turn (float): Actual current density in superconductor (A/m²). - j_tf_coil_turn (float): Actual current density in superconductor (A/m²). - b_tf_superconductor_critical_zero_temp_strain (float): Critical field at zero temperature and strain (T). - temp_tf_superconductor_critical_zero_field_strain (float): Critical temperature at zero field and strain (K). - c_tf_turn_cables_critical (float): Critical current in cable (A).

Notes

This routine calculates the superconductor properties for the TF coils. It was originally programmed by J. Galambos (1991), from algorithms provided by J. Miller. The routine calculates the critical current density (winding pack) and also the protection information (for a quench). Not used for the CroCo conductor.

The critical current density for a superconductor (j_superconductor_critical) is for the superconducting strands/tape, not including copper. The critical current density for a cable (j_crit_cable) accounts for both the fraction of the cable taken up by helium coolant channels, and the cable conductor copper fraction (i.e., the copper in the superconducting strands and any additional copper, such as REBCO tape support).

Source code in process/models/tfcoil/superconducting.py
 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
def tf_cable_in_conduit_superconductor_properties(
    self,
    a_tf_turn_cable_space: float,
    a_tf_turn: float,
    a_tf_turn_cable_space_effective: float,
    f_a_tf_turn_cable_space_cooling: float,
    b_tf_inboard_peak: float,
    f_a_tf_turn_cable_copper: float,
    c_tf_turn: float,
    j_tf_wp: float,
    i_tf_superconductor: int,
    f_strain_scale: float,
    temp_tf_coolant_peak_field: float,
    bcritsc: float,
    tcritsc: float,
) -> tuple[float, float, float, float, float, float, float, float]:
    """Calculates the properties of the TF superconducting conductor.

    Parameters
    ----------
    a_tf_turn_cable_space:
        Cable space - inside area (m²).
    a_tf_turn:
        Area per turn (i.e. entire jacketed conductor) (m²).
    a_tf_turn_cable_space_effective:
        Effective cable space area per turn (m²).
    f_a_tf_turn_cable_space_cooling:
        Fraction of cable space used for cooling.
    b_tf_inboard_peak:
        Peak field at conductor (T).
    f_a_tf_turn_cable_copper:
        Fraction of conductor that is copper.
    c_tf_turn:
        Operating current per turn (A).
    j_tf_wp:
        Actual winding pack current density (A/m²).
    i_tf_superconductor:
        Switch for conductor type:
        - 1: ITER Nb3Sn, standard parameters
        - 2: Bi-2212 High Temperature Superconductor
        - 3: NbTi
        - 4: ITER Nb3Sn, user-defined parameters
        - 5: WST Nb3Sn parameterisation
        - 7: Durham Ginzburg-Landau Nb-Ti parameterisation
        - 8: Durham Ginzburg-Landau critical surface model for REBCO
        - 9: Hazelton experimental data + Zhai conceptual model for REBCO
    f_strain_scale:
        Adjustment factor (<= 1) to account for strain, radiation damage, fatigue or AC losses.
    temp_tf_coolant_peak_field:
        He temperature at peak field point (K).
    bcritsc:
        Critical field at zero temperature and strain (T) (used only if i_tf_superconductor=4).
    tcritsc:
        Critical temperature at zero field and strain (K) (used only if i_tf_superconductor=4).

    Returns
    -------
    type
        tuple (float, float, float, float, float, float, float, float, float)
        - j_tf_wp_critical (float): Critical winding pack current density (A/m²).
        - j_superconductor_critical (float): Critical current density in superconductor (A/m²).
        - f_c_tf_turn_operating_critical (float): Ratio of operating / critical current.
        - j_superconductor_turn (float): Actual current density in superconductor (A/m²).
        - j_tf_coil_turn (float): Actual current density in superconductor (A/m²).
        - b_tf_superconductor_critical_zero_temp_strain (float): Critical field at zero temperature and strain (T).
        - temp_tf_superconductor_critical_zero_field_strain (float): Critical temperature at zero field and strain (K).
        - c_tf_turn_cables_critical (float): Critical current in cable (A).

    Notes
    -----
    This routine calculates the superconductor properties for the TF coils.
    It was originally programmed by J. Galambos (1991), from algorithms provided by J. Miller.
    The routine calculates the critical current density (winding pack) and also the protection
    information (for a quench). Not used for the CroCo conductor.

    The critical current density for a superconductor (``j_superconductor_critical``) is for the superconducting
    strands/tape, not including copper. The critical current density for a cable (``j_crit_cable``)
    accounts for both the fraction of the cable taken up by helium coolant channels, and the cable
    conductor copper fraction (i.e., the copper in the superconducting strands and any additional
    copper, such as REBCO tape support).
    """

    # Guard against negative conductor fraction f_a_tf_turn_cable_space_conductor
    # Kludge to allow solver to continue and hopefully be constrained away
    # from this point
    if f_a_tf_turn_cable_space_cooling > 0.99:
        f_a_tf_turn_cable_space_cooling = 0.99

    #  Conductor fraction (including central helium channel)
    f_a_tf_turn_cable_space_conductor = 1.0e0 - f_a_tf_turn_cable_space_cooling

    if tfcoil_variables.i_str_wp == 0:
        strain = tfcoil_variables.str_tf_con_res
    else:
        strain = tfcoil_variables.str_wp

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

    # ITER Nb3Sn critical surface parameterization
    if i_tf_superconductor == 1:
        # Peak field and temperature at zero strain
        bc20m = 32.97e0  # [T]
        tc0m = 16.06e0  # [K]

        # If strain limit achieved, throw a warning and use the lower strain
        if abs(strain) > 0.5e-2:
            logger.error(
                f"TF strain={strain} was outside the region of applicability. Used lower strain."
            )
            strain = np.sign(strain) * 0.5e-2

        #  j_superconductor_critical returned by superconductors.itersc is the critical current density in the
        #  superconductor - not the whole strand, which contains copper
        j_superconductor_critical, _, _ = superconductors.itersc(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            strain=strain,
            b_c20max=bc20m,
            temp_c0max=tc0m,
        )

        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calculation for costing in $/kAm
        # = Superconducting filaments jc * (1 - strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

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

    # Bi-2212 high temperature superconductor parameterization
    elif i_tf_superconductor == 2:
        #  Current density in a strand of Bi-2212 conductor
        #  N.B. jcrit returned by superconductors.bi2212 is the critical current density
        #  in the strand, not just the superconducting portion.
        #  The parameterization for j_crit_cable assumes a particular strand
        #  composition that does not require a user-defined copper fraction,
        #  so this is irrelevant in this model
        j_strand = (
            j_tf_wp
            * a_tf_turn
            / (a_tf_turn_cable_space * f_a_tf_turn_cable_space_conductor)
        )

        j_crit_cable, _ = superconductors.bi2212(
            b_conductor=b_tf_inboard_peak,
            jstrand=j_strand,
            temp_conductor=temp_tf_coolant_peak_field,
            f_strain=f_strain_scale,
        )
        j_superconductor_critical = j_crit_cable / (1.0e0 - f_a_tf_turn_cable_copper)
        #  Critical current in cable
        c_turn_cables_critical = (
            j_crit_cable * a_tf_turn_cable_space * f_a_tf_turn_cable_space_conductor
        )

        # Strand critical current calulation for costing in $ / kAm
        # Copper in the strand is already accounted for
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical
    # =================================================================

    # NbTi data
    elif i_tf_superconductor == 3:
        bc20m = 15.0e0  # [T]
        tc0m = 9.3e0  # [K]
        c0 = 1.0e10  # [A/m2]

        j_superconductor_critical, _ = superconductors.jcrit_nbti(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            c0=c0,
            b_c20m=bc20m,
            temp_c0max=tc0m,
        )

        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # = superconducting filaments jc * (1 -strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

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

    # ITER Nb3Sn parameterization, but user-defined parameters
    elif i_tf_superconductor == 4:
        bc20m = bcritsc  # [T]
        tc0m = tcritsc  # [K]

        # If strain limit achieved, throw a warning and use the lower strain
        if abs(strain) > 0.5e-2:
            logger.error(
                f"TF strain={strain} was outside the region of applicability. Used lower strain."
            )
            strain = np.sign(strain) * 0.5e-2

        j_superconductor_critical, _, _ = superconductors.itersc(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            strain=strain,
            b_c20max=bc20m,
            temp_c0max=tc0m,
        )
        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # = superconducting filaments jc * (1 -strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

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

    # WST Nb3Sn parameterisation
    elif i_tf_superconductor == 5:
        bc20m = 32.97e0  # [T]
        tc0m = 16.06e0  # [K]

        # If strain limit achieved, throw a warning and use the lower strain
        if abs(strain) > 0.5e-2:
            logger.error(
                f"TF strain={strain} was outside the region of applicability. Used lower strain."
            )
            strain = np.sign(strain) * 0.5e-2

        #  j_superconductor_critical returned by superconductors.itersc is the critical current density in the
        #  superconductor - not the whole strand, which contains copper
        j_superconductor_critical, _, _ = (
            superconductors.western_superconducting_nb3sn(
                temp_conductor=temp_tf_coolant_peak_field,
                b_conductor=b_tf_inboard_peak,
                strain=strain,
                b_c20max=bc20m,
                temp_c0max=tc0m,
            )
        )
        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # = superconducting filaments jc * (1 -strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

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

    # "REBCO" 2nd generation HTS superconductor in CrCo strand
    elif i_tf_superconductor == 6:
        raise ProcessValueError(
            "sctfcoil.supercon has been called but tfcoil_variables.i_tf_sc_mat=6"
        )

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

    # Durham Ginzburg-Landau Nb-Ti parameterisation
    elif i_tf_superconductor == 7:
        bc20m = tfcoil_variables.b_crit_upper_nbti  # [T]
        tc0m = tfcoil_variables.t_crit_nbti  # [K]

        j_superconductor_critical, _, _ = superconductors.gl_nbti(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            strain=strain,
            b_c20max=bc20m,
            t_c0=tc0m,
        )
        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # = superconducting filaments jc * (1 -strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

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

    # Durham Ginzburg-Landau critical surface model for REBCO
    elif i_tf_superconductor == 8:
        bc20m = 430  # [T]
        tc0m = 185  # [K]

        # If strain limit achieved, throw a warning and use the lower strain
        if abs(strain) > 0.7e-2:
            logger.error(
                f"TF strain={strain} was outside the region of applicability. Used lower strain."
            )
            strain = np.sign(strain) * 0.7e-2

        j_superconductor_critical, _, _ = superconductors.gl_rebco(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            strain=strain,
            b_c20max=bc20m,
            t_c0=tc0m,
        )
        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # Already includes buffer and support layers so no need to include f_a_tf_turn_cable_copper here
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical

        # REBCO measurements from 2 T to 14 T, extrapolating outside this
        if (b_tf_inboard_peak) >= 14.0:
            logger.error(
                "Field on superconductor > 14 T (outside of interpolation range)"
            )

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

    # Hazelton experimental data + Zhai conceptual model for REBCO
    elif i_tf_superconductor == 9:
        bc20m = 138  # [T]
        tc0m = 92  # [K]

        # If strain limit achieved, throw a warning and use the lower strain
        if abs(strain) > 0.7e-2:
            logger.error(
                f"TF strain={strain} was outside the region of applicability. Used lower strain."
            )
            strain = np.sign(strain) * 0.7e-2

        # 'high current density' as per parameterisation described in Wolf,
        #  and based on Hazelton experimental data and Zhai conceptual model;
        #  see subroutine for full references
        j_superconductor_critical, _, _ = superconductors.hijc_rebco(
            temp_conductor=temp_tf_coolant_peak_field,
            b_conductor=b_tf_inboard_peak,
            b_c20max=bc20m,
            t_c0=tc0m,
            dr_hts_tape=rebco_variables.dr_hts_tape,
            dx_hts_tape_rebco=rebco_variables.dx_hts_tape_rebco,
            dx_hts_tape_total=rebco_variables.dx_hts_tape_total,
        )
        # Scale for the copper area fraction of the cable
        j_cables_critical = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

        #  Critical current in turn all turn cables
        c_turn_cables_critical = j_cables_critical * a_tf_turn_cable_space_effective

        # Strand critical current calulation for costing in $ / kAm
        # = superconducting filaments jc * (1 -strand copper fraction)
        tfcoil_variables.j_crit_str_tf = j_superconductor_critical * (
            1.0e0 - f_a_tf_turn_cable_copper
        )

    else:
        raise ProcessValueError(
            "Illegal value for i_tf_sc_mat", i_tf_superconductor=i_tf_superconductor
        )

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

    # Critical current density in winding pack
    # a_tf_turn : Area per turn (i.e. entire jacketed conductor with insulation) (m2)
    j_tf_wp_critical = c_turn_cables_critical / a_tf_turn

    #  Ratio of operating / critical current
    f_c_tf_turn_operating_critical = c_tf_turn / c_turn_cables_critical

    #  Operating current density
    j_tf_coil_turn = c_tf_turn / a_tf_turn

    #  Actual current density in superconductor, not including copper

    j_superconductor = f_c_tf_turn_operating_critical * j_superconductor_critical

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

    if f_c_tf_turn_operating_critical <= 0e0:
        logger.error(
            f"""Negative Iop/Icrit for TF coil
        jsc: {j_superconductor}
        f_c_tf_turn_operating_critical: {f_c_tf_turn_operating_critical}
        j_superconductor_critical: {j_superconductor_critical}
        Check conductor dimensions. Cable space area a_tf_turn_cable_space likely gone negative. a_tf_turn_cable_space: {a_tf_turn_cable_space}
        This is likely because dr_tf_turn_cable_space or dx_tf_turn_cable_space has gone negative:
        dr_tf_turn_cable_space: {superconducting_tf_coil_variables.dr_tf_turn_cable_space}
        dx_tf_turn_cable_space: {superconducting_tf_coil_variables.dx_tf_turn_cable_space}
        """
        )

    return (
        j_tf_wp_critical,
        j_superconductor_critical,
        f_c_tf_turn_operating_critical,
        j_superconductor,
        j_tf_coil_turn,
        bc20m,
        tc0m,
        c_turn_cables_critical,
    )

calculate_cable_in_conduit_strand_count(a_cable_space, dia_superconductor_strand)

Calculates the maximum number of superconducting strands that can fit into a cable-in-conduit conductor, based on the available cable space, strand diameter, and desired void fraction.

Parameters:

Name Type Description Default
a_cable_space float

Total cross-sectional area available for the cable (in m²).

required
dia_superconductor_strand float

Diameter of a single superconducting strand (in meters).

required

Returns:

Type Description
int

The maximum number of strands that can fit in the available space, accounting for the void fraction.

Source code in process/models/tfcoil/superconducting.py
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
def calculate_cable_in_conduit_strand_count(
    self,
    a_cable_space: float,
    dia_superconductor_strand: float,
) -> int:
    """Calculates the maximum number of superconducting strands that can fit into a cable-in-conduit conductor,
    based on the available cable space, strand diameter, and desired void fraction.

    Parameters
    ----------
    a_cable_space : float
        Total cross-sectional area available for the cable (in m²).
    dia_superconductor_strand : float
        Diameter of a single superconducting strand (in meters).

    Returns
    -------
    int
        The maximum number of strands that can fit in the available space, accounting for the void fraction.
    """

    # Effective area available for strands (excluding voids)
    effective_area = a_cable_space

    # Area per strand (circular)
    strand_area = np.pi * (dia_superconductor_strand / 2) ** 2

    # Number of strands that fit
    return int(effective_area / strand_area)

calculate_cable_in_conduit_superconductor_length(n_tf_coils, n_tf_coil_turns, len_tf_coil, n_tf_turn_superconducting_cables)

Calculates the total length of superconducting material required for the TF coils.

Parameters:

Name Type Description Default
n_tf_coils int

n_tf_coils: Number of TF coils.

required
n_tf_coil_turns int

n_tf_coil_turns: Total number of turns in the TF coil winding pack.

required
len_tf_coil float

len_tf_coil: Length of a single TF coil (in meters).

required
n_tf_turn_superconducting_cables int

n_tf_turn_superconducting_cables: Number of superconducting cables per turn in the TF coil.

required

Returns:

Type Description
tuple[float, float]

Tuple containing: - Length of superconductor in one TF coil (in meters). - Total length of superconductor in all TF coils (in meters).

Source code in process/models/tfcoil/superconducting.py
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
def calculate_cable_in_conduit_superconductor_length(
    self,
    n_tf_coils: int,
    n_tf_coil_turns: int,
    len_tf_coil: float,
    n_tf_turn_superconducting_cables: int,
) -> float:
    """Calculates the total length of superconducting material required for the TF coils.

    Parameters
    ----------
    n_tf_coils: int :
        n_tf_coils: Number of TF coils.
    n_tf_coil_turns: int :
        n_tf_coil_turns: Total number of turns in the TF coil winding pack.
    len_tf_coil:
        len_tf_coil: Length of a single TF coil (in meters).
    n_tf_turn_superconducting_cables: int :
        n_tf_turn_superconducting_cables: Number of superconducting cables per turn in the TF coil.

    Returns
    -------
    tuple[float, float]
        Tuple containing:
        - Length of superconductor in one TF coil (in meters).
        - Total length of superconductor in all TF coils (in meters).
    """

    # Length of superconductor in one TF coil
    len_tf_coil_superconductor = (
        n_tf_coil_turns * len_tf_coil * n_tf_turn_superconducting_cables
    )

    # Total length of superconductor in all TF coils
    len_tf_superconductor_total = len_tf_coil_superconductor * n_tf_coils

    return len_tf_coil_superconductor, len_tf_superconductor_total

output_tf_superconductor_info()

Output TF superconductor information

Source code in process/models/tfcoil/superconducting.py
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
def output_tf_superconductor_info(self):
    """Output TF superconductor information"""

    po.oheadr(self.outfile, "TF Coils Superconductor Information")
    po.ovarin(
        self.outfile,
        "TF superconductor switch",
        "(i_tf_sc_mat)",
        tfcoil_variables.i_tf_sc_mat,
    )

    po.ocmmnt(
        self.outfile,
        f"Superconductor used: {SUPERCONDUCTING_TF_TYPES[tfcoil_variables.i_tf_sc_mat]}",
    )

    po.ovarre(
        self.outfile,
        "Critical field at zero temperature and strain (T)",
        "(b_tf_superconductor_critical_zero_temp_strain)",
        superconducting_tf_coil_variables.b_tf_superconductor_critical_zero_temp_strain,
    )
    po.ovarre(
        self.outfile,
        "Critical temperature at zero field and strain (K)",
        "(temp_tf_superconductor_critical_zero_field_strain)",
        superconducting_tf_coil_variables.temp_tf_superconductor_critical_zero_field_strain,
    )

    if global_variables.run_tests == 1:
        po.oblnkl(self.outfile)
        po.ocmmnt(
            self.outfile,
            "PROCESS TF Coil peak field fit. Values for t, z and y:",
        )
        po.oblnkl(self.outfile)
        po.ovarre(
            self.outfile,
            "Dimensionless winding pack width",
            "(tf_fit_t)",
            superconducting_tf_coil_variables.tf_fit_t,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Dimensionless winding pack radial thickness",
            "(tf_fit_z)",
            superconducting_tf_coil_variables.tf_fit_z,
            "OP ",
        )
        po.ovarre(
            self.outfile,
            "Ratio of peak field with ripple to nominal axisymmetric peak field",
            "(f_b_tf_inboard_peak_ripple_symmetric)",
            superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric,
            "OP ",
        )

    po.oblnkl(self.outfile)
    po.ovarre(
        self.outfile,
        "Helium temperature at peak field (= superconductor temperature) (K)",
        "(tftmp)",
        tfcoil_variables.tftmp,
    )
    po.ovarre(
        self.outfile,
        "Total cooling area fraction inside cable space",
        "(f_a_tf_turn_cable_space_cooling)",
        superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Copper fraction of conductor",
        "(f_a_tf_turn_cable_copper)",
        tfcoil_variables.f_a_tf_turn_cable_copper,
    )
    po.ovarre(
        self.outfile,
        "Residual manufacturing strain on superconductor",
        "(str_tf_con_res)",
        tfcoil_variables.str_tf_con_res,
    )
    po.ovarre(
        self.outfile,
        "Self-consistent strain on superconductor",
        "(str_wp)",
        tfcoil_variables.str_wp,
    )
    po.ovarre(
        self.outfile,
        "Critical current density in superconductor (A/m2)",
        "(j_tf_superconductor_critical)",
        superconducting_tf_coil_variables.j_tf_superconductor_critical,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Critical current density in winding pack (A/m2)",
        "(j_tf_wp_critical)",
        tfcoil_variables.j_tf_wp_critical,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Actual current density in winding pack (A/m2)",
        "(j_tf_coil_turn)",
        superconducting_tf_coil_variables.j_tf_coil_turn,
        "OP ",
    )

    po.ovarre(
        self.outfile,
        "Minimum allowed temperature margin in superconductor (K)",
        "(temp_tf_superconductor_margin_min)",
        tfcoil_variables.temp_tf_superconductor_margin_min,
    )
    po.ovarre(
        self.outfile,
        "Actual temperature margin in superconductor (K)",
        "(temp_tf_superconductor_margin)",
        tfcoil_variables.temp_tf_superconductor_margin,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Critical current (A)",
        "(c_turn_cables_critical)",
        superconducting_tf_coil_variables.c_tf_turn_cables_critical,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Actual current (A)",
        "(c_tf_turn)",
        tfcoil_variables.c_tf_turn,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Actual current / critical current",
        "(f_c_tf_turn_operating_critical)",
        superconducting_tf_coil_variables.f_c_tf_turn_operating_critical,
        "OP ",
    )
    if superconducting_tf_coil_variables.f_c_tf_turn_operating_critical > 0.7:
        logger.error(
            "f_c_tf_turn_operating_critical shouldn't be above 0.7 for engineering reliability"
        )

    po.ovarre(
        self.outfile,
        "TF Superconductor quench dump time (s)",
        "(t_tf_superconductor_quench)",
        tfcoil_variables.t_tf_superconductor_quench,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "TF Superconductor quench detection time (s)",
        "(t_tf_quench_detection)",
        tfcoil_variables.t_tf_quench_detection,
        "OP ",
    )
    po.ovarre(
        self.outfile,
        "Maximum winding pack current density for protection (A/m2)",
        "(j_tf_wp_quench_heat_max)",
        tfcoil_variables.j_tf_wp_quench_heat_max,
        "OP ",
    )

calculate_superconductor_temperature_margin(i_tf_superconductor, j_superconductor, b_tf_inboard_peak, strain, bc20m, tc0m, c0, temp_tf_coolant_peak_field)

Calculate the temperature margin of the TF superconductor.

Parameters:

Name Type Description Default
i_tf_superconductor int

Switch for conductor type: - 1: ITER Nb3Sn, standard parameters - 2: Bi-2212 High Temperature Superconductor - 3: NbTi - 4: ITER Nb3Sn, user-defined parameters - 5: WST Nb3Sn parameterisation - 7: Durham Ginzburg-Landau Nb-Ti parameterisation - 8: Durham Ginzburg-Landau critical surface model for REBCO - 9: Hazelton experimental data + Zhai conceptual model for REBCO

required
j_superconductor float

Current density in superconductor (A/m²).

required
b_tf_inboard_peak float

Peak field at conductor (T).

required
strain float

Strain on superconductor.

required
bc20m float

Critical field at zero temperature and strain (T).

required
tc0m float

Critical temperature at zero field and strain (K).

required
c0 float

Constant used in NbTi critical current density calculation (A/m²).

required
temp_tf_coolant_peak_field float

He temperature at peak field point (K).

required

Returns:

Type Description
type

temp_tf_superconductor_margin.

Source code in process/models/tfcoil/superconducting.py
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
def calculate_superconductor_temperature_margin(
    self,
    i_tf_superconductor: int,
    j_superconductor: float,
    b_tf_inboard_peak: float,
    strain: float,
    bc20m: float,
    tc0m: float,
    c0: float,
    temp_tf_coolant_peak_field: float,
):
    """Calculate the temperature margin of the TF superconductor.

    Parameters
    ----------
    i_tf_superconductor:
        Switch for conductor type:
        - 1: ITER Nb3Sn, standard parameters
        - 2: Bi-2212 High Temperature Superconductor
        - 3: NbTi
        - 4: ITER Nb3Sn, user-defined parameters
        - 5: WST Nb3Sn parameterisation
        - 7: Durham Ginzburg-Landau Nb-Ti parameterisation
        - 8: Durham Ginzburg-Landau critical surface model for REBCO
        - 9: Hazelton experimental data + Zhai conceptual model for REBCO
    j_superconductor:
        Current density in superconductor (A/m²).
    b_tf_inboard_peak:
        Peak field at conductor (T).
    strain:
        Strain on superconductor.
    bc20m:
        Critical field at zero temperature and strain (T).
    tc0m:
        Critical temperature at zero field and strain (K).
    c0:
        Constant used in NbTi critical current density calculation (A/m²).
    temp_tf_coolant_peak_field:
        He temperature at peak field point (K).

    Returns
    -------
    type
        temp_tf_superconductor_margin.
    """

    # =================================================================
    # Calculate temperature margin of superconductor

    #  Temperature margin (already calculated in superconductors.bi2212 for i_tf_superconductor=2)

    if i_tf_superconductor in (
        1,
        3,
        4,
        5,
        7,
        8,
        9,
    ):  # Find temperature at which current density margin = 0
        if i_tf_superconductor == 3:
            arguments = (
                i_tf_superconductor,
                j_superconductor,
                b_tf_inboard_peak,
                strain,
                bc20m,
                tc0m,
                c0,
            )
        else:
            arguments = (
                i_tf_superconductor,
                j_superconductor,
                b_tf_inboard_peak,
                strain,
                bc20m,
                tc0m,
            )

        another_estimate = 2 * temp_tf_coolant_peak_field
        (
            t_zero_margin,
            _root_result,
        ) = optimize.newton(
            superconductors.superconductor_current_density_margin,
            temp_tf_coolant_peak_field,
            fprime=None,
            args=arguments,
            tol=1.0e-06,
            maxiter=50,
            fprime2=None,
            x1=another_estimate,
            rtol=1.0e-6,
            full_output=True,
            disp=True,
        )
        # print(root_result)  # Diagnostic for newton method
        temp_tf_superconductor_margin = t_zero_margin - temp_tf_coolant_peak_field
        tfcoil_variables.temp_margin = temp_tf_superconductor_margin

        if temp_tf_superconductor_margin <= 0.0e0:
            logger.error(
                """Negative TFC temperature margin
            temp_tf_superconductor_margin: {temp_tf_superconductor_margin}
            b_tf_inboard_peak: {b_tf_inboard_peak}
            j_superconductor: {j_superconductor}
            """
            )

    return temp_tf_superconductor_margin

quench_heat_protection_current_density(c_tf_turn, e_tf_coil_magnetic_stored, a_tf_turn_cable_space, a_tf_turn, t_tf_quench_dump, f_a_tf_turn_cable_space_conductor, f_a_tf_turn_cable_copper, temp_tf_coolant_peak_field, temp_tf_conductor_quench_max, b_tf_inboard_peak, cu_rrr, t_tf_quench_detection, nflutfmax)

Calculates the maximum conductor current density limited by the protection limit, and the discharge voltage for a TF coil.

Parameters:

Name Type Description Default
c_tf_turn float

Operating current (A)

required
e_tf_coil_magnetic_stored float

Energy stored in one TF coil (J)

required
a_tf_turn_cable_space float

Cable space - inside area (m²)

required
a_tf_turn float

Area per turn (i.e. entire cable) (m²)

required
t_tf_quench_dump float

Dump time (s)

required
f_a_tf_turn_cable_space_conductor float

Fraction of cable space containing conductor

required
f_a_tf_turn_cable_copper float

Fraction of conductor that is copper

required
temp_tf_coolant_peak_field float

Helium temperature at peak field point (K)

required
temp_tf_conductor_quench_max float

Maximum conductor temperature during quench (K)

required
b_tf_inboard_peak float

Peak magnetic field at conductor (T)

required
cu_rrr float

Copper residual-resistance-ratio

required
t_tf_quench_detection float

Quench detection time (s)

required
nflutfmax float

End-of-life neutron fluence in the copper (1/m²)

required

Returns:

Type Description
tuple[float, float]

j_tf_wp_quench_protection_max (float): Winding pack current density from temperature rise protection (A/m²) - v_tf_dump_voltage_peak (float): Discharge voltage imposed on a TF coil (V)

References
Source code in process/models/tfcoil/superconducting.py
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
def quench_heat_protection_current_density(
    self,
    c_tf_turn: float,
    e_tf_coil_magnetic_stored: float,
    a_tf_turn_cable_space: float,
    a_tf_turn: float,
    t_tf_quench_dump: float,
    f_a_tf_turn_cable_space_conductor: float,
    f_a_tf_turn_cable_copper: float,
    temp_tf_coolant_peak_field: float,
    temp_tf_conductor_quench_max: float,
    b_tf_inboard_peak: float,
    cu_rrr: float,
    t_tf_quench_detection: float,
    nflutfmax: float,
) -> tuple[float, float]:
    """Calculates the maximum conductor current density limited by the protection limit,
    and the discharge voltage for a TF coil.

    Parameters
    ----------
    c_tf_turn : float
        Operating current (A)
    e_tf_coil_magnetic_stored : float
        Energy stored in one TF coil (J)
    a_tf_turn_cable_space : float
        Cable space - inside area (m²)
    a_tf_turn : float
        Area per turn (i.e. entire cable) (m²)
    t_tf_quench_dump : float
        Dump time (s)
    f_a_tf_turn_cable_space_conductor : float
        Fraction of cable space containing conductor
    f_a_tf_turn_cable_copper : float
        Fraction of conductor that is copper
    temp_tf_coolant_peak_field : float
        Helium temperature at peak field point (K)
    temp_tf_conductor_quench_max : float
        Maximum conductor temperature during quench (K)
    b_tf_inboard_peak : float
        Peak magnetic field at conductor (T)
    cu_rrr : float
        Copper residual-resistance-ratio
    t_tf_quench_detection : float
        Quench detection time (s)
    nflutfmax : float
        End-of-life neutron fluence in the copper (1/m²)

    Returns
    -------
    tuple[float, float]
        j_tf_wp_quench_protection_max (float): Winding pack current density from temperature rise protection (A/m²)
        - v_tf_dump_voltage_peak (float): Discharge voltage imposed on a TF coil (V)

    References
    ----------
    - L. Bottura, “Magnet Quench 101,” arXiv (Cornell University), Jan. 2014,
    doi: https://doi.org/10.48550/arxiv.1401.3927.
    """

    #  Peak Dump voltage
    v_tf_dump_voltage_peak = (
        2.0e0 * e_tf_coil_magnetic_stored / (t_tf_quench_dump * c_tf_turn)
    )

    # Winding pack current density from temperature rise protection
    j_tf_wp_quench_protection_max = (
        a_tf_turn_cable_space
        / a_tf_turn
        * quench.calculate_quench_protection_current_density(
            t_tf_quench_dump,
            b_tf_inboard_peak,
            f_a_tf_turn_cable_copper,
            1.0 - f_a_tf_turn_cable_space_conductor,
            temp_tf_coolant_peak_field,
            temp_tf_conductor_quench_max,
            cu_rrr,
            t_tf_quench_detection,
            nflutfmax,
        )
    )

    return j_tf_wp_quench_protection_max, v_tf_dump_voltage_peak

vv_stress_on_quench()

Calculate the Tresca stress [Pa] of the Vacuum Vessel (VV) experienced when the TF coil quenches.

Assumes the current center line (CCL) of the TF coil is the middle of the coil.

We assume vertical symmetry which is only true for double null machines.

Source code in process/models/tfcoil/superconducting.py
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
def vv_stress_on_quench(self):
    """Calculate the Tresca stress [Pa] of the Vacuum Vessel (VV)
    experienced when the TF coil quenches.

    Assumes the current center line (CCL) of the TF coil is the
    middle of the coil.

    We assume vertical symmetry which is only true for double null
    machines.
    """
    H_coil = build_variables.z_tf_inside_half + (build_variables.dr_tf_inboard / 2)
    ri_coil = build_variables.r_tf_inboard_mid
    ro_coil = build_variables.r_tf_outboard_mid
    # NOTE: rm is measured from the outside edge of the coil because thats where
    # the radius of the first ellipse is measured from
    rm_coil = build_variables.r_tf_inboard_out + tfcoil_variables.tfa[0]

    H_vv = (
        build_variables.z_plasma_xpoint_upper
        + build_variables.dz_xpoint_divertor
        + divertor_variables.dz_divertor
        + build_variables.dz_shld_upper
        + (build_variables.dz_vv_upper / 2)
    )
    # ri and ro for VV dont consider the shield widths
    # because it is assumed the shield is on the plasma side
    # of the VV
    ri_vv = build_variables.r_vv_inboard_out - (build_variables.dr_vv_outboard / 2)
    ro_vv = (
        build_variables.r_tf_outboard_mid
        - (build_variables.dr_tf_outboard / 2)
        - build_variables.dr_tf_shld_gap
        - build_variables.dr_shld_thermal_outboard
        - build_variables.dr_shld_vv_gap_outboard
        - (build_variables.dr_vv_outboard / 2)
    )

    # Assume the radius of the first ellipse of the VV is in the same proportion to
    # that of the plasma facing radii of the two structures
    tf_vv_frac = build_variables.r_tf_inboard_out / build_variables.r_vv_inboard_out
    rm_vv = build_variables.r_vv_inboard_out + (tfcoil_variables.tfa[0] * tf_vv_frac)

    superconducting_tf_coil_variables.vv_stress_quench = vv_stress_on_quench(
        # TF shape
        H_coil=H_coil,
        ri_coil=ri_coil,
        ro_coil=ro_coil,
        rm_coil=rm_coil,
        ccl_length_coil=tfcoil_variables.len_tf_coil,
        theta1_coil=tfcoil_variables.theta1_coil,
        # VV shape
        H_vv=H_vv,
        ri_vv=ri_vv,
        ro_vv=ro_vv,
        rm_vv=rm_vv,
        theta1_vv=tfcoil_variables.theta1_vv,
        # TF properties
        n_tf_coils=tfcoil_variables.n_tf_coils,
        n_tf_coil_turns=tfcoil_variables.n_tf_coil_turns,
        # Area of the radial plate taken to be the area of steel in the WP
        # TODO: value clipped due to #1883
        s_rp=np.clip(
            superconducting_tf_coil_variables.a_tf_coil_inboard_steel, 0, None
        ),
        s_cc=superconducting_tf_coil_variables.a_tf_plasma_case
        + superconducting_tf_coil_variables.a_tf_coil_nose_case
        + 2.0 * superconducting_tf_coil_variables.dx_tf_side_case_average,
        taud=tfcoil_variables.t_tf_superconductor_quench,
        # TODO: is this the correct current?
        i_op=superconducting_tf_coil_variables.c_tf_coil
        / tfcoil_variables.n_tf_coil_turns,
        # VV properties
        d_vv=build_variables.dr_vv_shells,
    )

peak_b_tf_inboard_with_ripple(n_tf_coils, dx_tf_wp_primary_toroidal, dr_tf_wp_no_insulation, r_tf_wp_inboard_centre, b_tf_inboard_peak_symmetric)

Calculates the peak toroidal field at the outboard edge of the inboard TF coil winding pack, including the effects of ripple.

For 16, 18, or 20 coils, uses fitting formulae derived by M. Kovari using MAGINT calculations on coil sets based on a DEMO1 case. For other numbers of coils, uses a 9% increase due to ripple from the axisymmetric calculation.

Parameters:

Name Type Description Default
n_tf_coils float

Number of TF coils.

required
dx_tf_wp_primary_toroidal float

Width of plasma-facing face of winding pack (m).

required
dr_tf_wp_no_insulation float

Radial thickness of winding pack with no insulation (e.g. conductor region) (m).

required
r_tf_wp_inboard_centre float

Major radius of centre of winding pack (m).

required
b_tf_inboard_peak_symmetric float

Nominal (axisymmetric) peak toroidal field (T).

required

Returns:

Type Description
tuple[float]

Tuple containing: - b_tf_inboard_peak_with_ripple (float): Peak toroidal field including ripple (T).

Notes
  • M. Kovari, Toroidal Field Coils - Maximum Field and Ripple - Parametric Calculation, July 2014.
Source code in process/models/tfcoil/superconducting.py
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
def peak_b_tf_inboard_with_ripple(
    self,
    n_tf_coils: float,
    dx_tf_wp_primary_toroidal: float,
    dr_tf_wp_no_insulation: float,
    r_tf_wp_inboard_centre: float,
    b_tf_inboard_peak_symmetric: float,
) -> tuple[float, int]:
    """Calculates the peak toroidal field at the outboard edge of the inboard TF coil winding pack,
    including the effects of ripple.

    For 16, 18, or 20 coils, uses fitting formulae derived by M. Kovari using MAGINT calculations
    on coil sets based on a DEMO1 case. For other numbers of coils, uses a 9% increase due to ripple
    from the axisymmetric calculation.

    Parameters
    ----------
    n_tf_coils : float
        Number of TF coils.
    dx_tf_wp_primary_toroidal : float
        Width of plasma-facing face of winding pack (m).
    dr_tf_wp_no_insulation : float
        Radial thickness of winding pack with no insulation (e.g. conductor region) (m).
    r_tf_wp_inboard_centre : float
        Major radius of centre of winding pack (m).
    b_tf_inboard_peak_symmetric : float
        Nominal (axisymmetric) peak toroidal field (T).

    Returns
    -------
    tuple[float]
        Tuple containing:
        - b_tf_inboard_peak_with_ripple (float): Peak toroidal field including ripple (T).

    Notes
    -----
    - M. Kovari, Toroidal Field Coils - Maximum Field and Ripple - Parametric Calculation, July 2014.
    """
    a = np.zeros((4,))

    #  Set fitting coefficients for different numbers of TF coils

    int_n_tf = np.round(n_tf_coils)

    if int_n_tf == 16:
        a[0] = 0.28101e0
        a[1] = 1.8481e0
        a[2] = -0.88159e0
        a[3] = 0.93834e0
    elif int_n_tf == 18:
        a[0] = 0.29153e0
        a[1] = 1.81600e0
        a[2] = -0.84178e0
        a[3] = 0.90426e0
    elif int_n_tf == 20:
        a[0] = 0.29853e0
        a[1] = 1.82130e0
        a[2] = -0.85031e0
        a[3] = 0.89808e0

    else:
        return 1.09e0 * b_tf_inboard_peak_symmetric

    #  Maximum winding pack width before adjacent packs touch
    #  (ignoring the external case and ground wall thicknesses)

    dx_tf_wp_toroidal_max = (
        2.0e0 * r_tf_wp_inboard_centre + dr_tf_wp_no_insulation
    ) * np.tan(np.pi / n_tf_coils)

    #  Dimensionless winding pack width

    superconducting_tf_coil_variables.tf_fit_t = (
        dx_tf_wp_primary_toroidal / dx_tf_wp_toroidal_max
    )
    if (superconducting_tf_coil_variables.tf_fit_t < 0.3e0) or (
        superconducting_tf_coil_variables.tf_fit_t > 1.1e0
    ):
        logger.warning(
            "(TF coil peak field calculation) Winding pack width out of fitted range"
        )

    #  Dimensionless winding pack radial thickness

    superconducting_tf_coil_variables.tf_fit_z = (
        dr_tf_wp_no_insulation / dx_tf_wp_toroidal_max
    )
    if (superconducting_tf_coil_variables.tf_fit_z < 0.26e0) or (
        superconducting_tf_coil_variables.tf_fit_z > 0.7e0
    ):
        # write(*,*) 'PEAK_TF_WITH_RIPPLE: fitting problem; z = ',z
        logger.warning(
            "(TF coil peak field calculation) Winding pack radial thickness out of fitted range"
        )

    #  Ratio of peak field with ripple to nominal axisymmetric peak field

    superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric = (
        a[0]
        + a[1] * np.exp(-superconducting_tf_coil_variables.tf_fit_t)
        + a[2] * superconducting_tf_coil_variables.tf_fit_z
        + a[3]
        * superconducting_tf_coil_variables.tf_fit_z
        * superconducting_tf_coil_variables.tf_fit_t
    )

    return (
        superconducting_tf_coil_variables.f_b_tf_inboard_peak_ripple_symmetric
        * b_tf_inboard_peak_symmetric
    )

sc_tf_internal_geom(i_tf_wp_geom, i_tf_case_geom, i_tf_turns_integer)

Seting the WP, case and turns geometry for SC magnets

Parameters:

Name Type Description Default
i_tf_wp_geom
required
i_tf_case_geom
required
i_tf_turns_integer
required
Source code in process/models/tfcoil/superconducting.py
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
def sc_tf_internal_geom(self, i_tf_wp_geom, i_tf_case_geom, i_tf_turns_integer):
    """
    Seting the WP, case and turns geometry for SC magnets

    Parameters
    ----------
    i_tf_wp_geom :

    i_tf_case_geom :

    i_tf_turns_integer :

    """

    # Calculating the WP / ground insulation areas
    (
        superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
        superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
        superconducting_tf_coil_variables.r_tf_wp_inboard_centre,
        superconducting_tf_coil_variables.dx_tf_wp_toroidal_min,
        superconducting_tf_coil_variables.dr_tf_wp_no_insulation,
        tfcoil_variables.dx_tf_wp_primary_toroidal,
        tfcoil_variables.dx_tf_wp_secondary_toroidal,
        superconducting_tf_coil_variables.dx_tf_wp_toroidal_average,
        superconducting_tf_coil_variables.a_tf_wp_with_insulation,
        superconducting_tf_coil_variables.a_tf_wp_no_insulation,
        superconducting_tf_coil_variables.a_tf_wp_ground_insulation,
    ) = self.superconducting_tf_wp_geometry(
        i_tf_wp_geom=i_tf_wp_geom,
        r_tf_inboard_in=build_variables.r_tf_inboard_in,
        dr_tf_nose_case=tfcoil_variables.dr_tf_nose_case,
        dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
        tan_theta_coil=superconducting_tf_coil_variables.tan_theta_coil,
        dx_tf_side_case_min=tfcoil_variables.dx_tf_side_case_min,
        dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
        dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
    )

    # Calculating the TF steel casing areas
    (
        tfcoil_variables.a_tf_coil_inboard_case,
        tfcoil_variables.a_tf_coil_outboard_case,
        superconducting_tf_coil_variables.a_tf_plasma_case,
        superconducting_tf_coil_variables.a_tf_coil_nose_case,
        superconducting_tf_coil_variables.dx_tf_side_case_average,
        superconducting_tf_coil_variables.dx_tf_side_case_peak,
    ) = self.superconducting_tf_case_geometry(
        i_tf_case_geom=i_tf_case_geom,
        i_tf_wp_geom=i_tf_wp_geom,
        a_tf_inboard_total=tfcoil_variables.a_tf_inboard_total,
        n_tf_coils=tfcoil_variables.n_tf_coils,
        a_tf_wp_with_insulation=superconducting_tf_coil_variables.a_tf_wp_with_insulation,
        a_tf_leg_outboard=tfcoil_variables.a_tf_leg_outboard,
        rad_tf_coil_inboard_toroidal_half=superconducting_tf_coil_variables.rad_tf_coil_inboard_toroidal_half,
        r_tf_inboard_out=build_variables.r_tf_inboard_out,
        tan_theta_coil=superconducting_tf_coil_variables.tan_theta_coil,
        r_tf_wp_inboard_outer=superconducting_tf_coil_variables.r_tf_wp_inboard_outer,
        dr_tf_plasma_case=tfcoil_variables.dr_tf_plasma_case,
        r_tf_wp_inboard_inner=superconducting_tf_coil_variables.r_tf_wp_inboard_inner,
        r_tf_inboard_in=build_variables.r_tf_inboard_in,
        dx_tf_side_case_min=tfcoil_variables.dx_tf_side_case_min,
        dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
    )

    # WP/trun currents
    self.tf_wp_currents()

    # Setting the WP turn geometry / areas
    if i_tf_turns_integer == 0:
        # Non-ingeger number of turns
        (
            tfcoil_variables.a_tf_turn_cable_space_no_void,
            tfcoil_variables.a_tf_turn_steel,
            tfcoil_variables.a_tf_turn_insulation,
            tfcoil_variables.n_tf_coil_turns,
            tfcoil_variables.dx_tf_turn_general,
            tfcoil_variables.c_tf_turn,
            tfcoil_variables.dx_tf_turn_general,
            superconducting_tf_coil_variables.dr_tf_turn,
            superconducting_tf_coil_variables.dx_tf_turn,
            tfcoil_variables.t_conductor,
            superconducting_tf_coil_variables.radius_tf_turn_cable_space_corners,
            superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
            superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
            superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling,
        ) = self.tf_cable_in_conduit_averaged_turn_geometry(
            j_tf_wp=tfcoil_variables.j_tf_wp,
            dx_tf_turn_steel=tfcoil_variables.dx_tf_turn_steel,
            dx_tf_turn_insulation=tfcoil_variables.dx_tf_turn_insulation,
            i_tf_sc_mat=tfcoil_variables.i_tf_sc_mat,
            dx_tf_turn_general=tfcoil_variables.dx_tf_turn_general,
            c_tf_turn=tfcoil_variables.c_tf_turn,
            i_dx_tf_turn_general_input=tfcoil_variables.i_dx_tf_turn_general_input,
            i_dx_tf_turn_cable_space_general_input=tfcoil_variables.i_dx_tf_turn_cable_space_general_input,
            dx_tf_turn_cable_space_general=tfcoil_variables.dx_tf_turn_cable_space_general,
            layer_ins=tfcoil_variables.layer_ins,
            a_tf_wp_no_insulation=superconducting_tf_coil_variables.a_tf_wp_no_insulation,
            dia_tf_turn_coolant_channel=tfcoil_variables.dia_tf_turn_coolant_channel,
            f_a_tf_turn_cable_space_extra_void=tfcoil_variables.f_a_tf_turn_cable_space_extra_void,
        )

    else:
        # Integer number of turns
        (
            superconducting_tf_coil_variables.radius_tf_turn_cable_space_corners,
            superconducting_tf_coil_variables.dr_tf_turn,
            superconducting_tf_coil_variables.dx_tf_turn,
            tfcoil_variables.a_tf_turn_cable_space_no_void,
            tfcoil_variables.a_tf_turn_steel,
            tfcoil_variables.a_tf_turn_insulation,
            tfcoil_variables.c_tf_turn,
            tfcoil_variables.n_tf_coil_turns,
            superconducting_tf_coil_variables.t_conductor_radial,
            superconducting_tf_coil_variables.t_conductor_toroidal,
            tfcoil_variables.t_conductor,
            superconducting_tf_coil_variables.dr_tf_turn_cable_space,
            superconducting_tf_coil_variables.dx_tf_turn_cable_space,
            superconducting_tf_coil_variables.dx_tf_turn_cable_space_average,
        ) = self.tf_cable_in_conduit_integer_turn_geometry(
            dr_tf_wp_with_insulation=tfcoil_variables.dr_tf_wp_with_insulation,
            dx_tf_wp_insulation=tfcoil_variables.dx_tf_wp_insulation,
            dx_tf_wp_insertion_gap=tfcoil_variables.dx_tf_wp_insertion_gap,
            n_tf_wp_layers=tfcoil_variables.n_tf_wp_layers,
            dx_tf_wp_toroidal_min=superconducting_tf_coil_variables.dx_tf_wp_toroidal_min,
            n_tf_wp_pancakes=tfcoil_variables.n_tf_wp_pancakes,
            c_tf_coil=superconducting_tf_coil_variables.c_tf_coil,
            dx_tf_turn_steel=tfcoil_variables.dx_tf_turn_steel,
            dx_tf_turn_insulation=tfcoil_variables.dx_tf_turn_insulation,
        )

    # Calculate number of cables in turn if CICC conductor
    # ---------------------------------------------------
    if tfcoil_variables.i_tf_sc_mat != 6:
        superconducting_tf_coil_variables.n_tf_turn_superconducting_cables = self.calculate_cable_in_conduit_strand_count(
            a_cable_space=superconducting_tf_coil_variables.a_tf_turn_cable_space_effective,
            dia_superconductor_strand=superconducting_tf_coil_variables.dia_tf_turn_superconducting_cable,
        )

        (
            superconducting_tf_coil_variables.len_tf_coil_superconductor,
            superconducting_tf_coil_variables.len_tf_superconductor_total,
        ) = self.calculate_cable_in_conduit_superconductor_length(
            n_tf_coils=tfcoil_variables.n_tf_coils,
            n_tf_coil_turns=tfcoil_variables.n_tf_coil_turns,
            len_tf_coil=tfcoil_variables.len_tf_coil,
            n_tf_turn_superconducting_cables=superconducting_tf_coil_variables.n_tf_turn_superconducting_cables,
        )

    # Areas and fractions
    # -------------------
    # Central helium channel down the conductor core [m2]
    tfcoil_variables.a_tf_wp_coolant_channels = (
        0.25e0
        * tfcoil_variables.n_tf_coil_turns
        * np.pi
        * tfcoil_variables.dia_tf_turn_coolant_channel**2
    )

    # Total conductor cross-sectional area, taking account of void area
    # and central helium channel [m2]
    tfcoil_variables.a_tf_wp_conductor = (
        tfcoil_variables.a_tf_turn_cable_space_no_void
        * tfcoil_variables.n_tf_coil_turns
        * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
        - tfcoil_variables.a_tf_wp_coolant_channels
    )

    # Void area in conductor for He, not including central channel [m2]
    tfcoil_variables.a_tf_wp_extra_void = (
        tfcoil_variables.a_tf_turn_cable_space_no_void
        * tfcoil_variables.n_tf_coil_turns
        * tfcoil_variables.f_a_tf_turn_cable_space_extra_void
    )

    # Area of inter-turn insulation: total [m2]
    tfcoil_variables.a_tf_coil_wp_turn_insulation = (
        tfcoil_variables.n_tf_coil_turns * tfcoil_variables.a_tf_turn_insulation
    )

    # Area of steel structure in winding pack [m2]
    tfcoil_variables.a_tf_wp_steel = (
        tfcoil_variables.n_tf_coil_turns * tfcoil_variables.a_tf_turn_steel
    )

    # Inboard coil steel area [m2]
    superconducting_tf_coil_variables.a_tf_coil_inboard_steel = (
        tfcoil_variables.a_tf_coil_inboard_case + tfcoil_variables.a_tf_wp_steel
    )

    # Inboard coil steel fraction [-]
    superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel = (
        tfcoil_variables.n_tf_coils
        * superconducting_tf_coil_variables.a_tf_coil_inboard_steel
        / tfcoil_variables.a_tf_inboard_total
    )

    # Inboard coil insulation cross-section [m2]
    superconducting_tf_coil_variables.a_tf_coil_inboard_insulation = (
        tfcoil_variables.a_tf_coil_wp_turn_insulation
        + superconducting_tf_coil_variables.a_tf_wp_ground_insulation
    )

    #  Inboard coil insulation fraction [-]
    superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation = (
        tfcoil_variables.n_tf_coils
        * superconducting_tf_coil_variables.a_tf_coil_inboard_insulation
        / tfcoil_variables.a_tf_inboard_total
    )

    # Negative areas or fractions error reporting
    if (
        tfcoil_variables.a_tf_wp_conductor <= 0.0e0
        or tfcoil_variables.a_tf_wp_extra_void <= 0.0e0
        or tfcoil_variables.a_tf_coil_wp_turn_insulation <= 0.0e0
        or tfcoil_variables.a_tf_wp_steel <= 0.0e0
        or superconducting_tf_coil_variables.a_tf_coil_inboard_steel <= 0.0e0
        or superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel <= 0.0e0
        or superconducting_tf_coil_variables.a_tf_coil_inboard_insulation <= 0.0e0
        or superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation <= 0.0e0
    ):
        logger.error(
            "One of the areas or fractions is negative in the internal SC TF coil geometry"
            f"{tfcoil_variables.a_tf_wp_conductor=} {tfcoil_variables.a_tf_wp_extra_void=}"
            f"{tfcoil_variables.a_tf_coil_wp_turn_insulation=} {tfcoil_variables.a_tf_wp_steel=}"
            f"{superconducting_tf_coil_variables.a_tf_coil_inboard_steel=} {superconducting_tf_coil_variables.f_a_tf_coil_inboard_steel=}"
            f"{superconducting_tf_coil_variables.a_tf_coil_inboard_insulation=} {superconducting_tf_coil_variables.f_a_tf_coil_inboard_insulation=}"
        )

superconducting_tf_wp_geometry(i_tf_wp_geom, r_tf_inboard_in, dr_tf_nose_case, dr_tf_wp_with_insulation, tan_theta_coil, dx_tf_side_case_min, dx_tf_wp_insulation, dx_tf_wp_insertion_gap)

Calculates the winding pack (WP) geometry and cross-sectional areas for superconducting toroidal field (TF) coils.

Parameters:

Name Type Description Default
i_tf_wp_geom int

0: Rectangular - 1: Double rectangular - 2: Trapezoidal

required
r_tf_inboard_in float

Inboard inner radius [m].

required
dr_tf_nose_case float

Radial thickness of nose case [m].

required
dr_tf_wp_with_insulation float

Radial thickness of winding pack including insulation [m].

required
tan_theta_coil float

Tangent of coil half angle [-].

required
dx_tf_side_case_min float

Side case thickness [m].

required
dx_tf_wp_insulation float

Insulation thickness [m].

required
dx_tf_wp_insertion_gap float

Insertion gap thickness [m].

required

Returns:

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

Tuple containing: - r_tf_wp_inboard_inner (float): WP inboard inner radius [m] - r_tf_wp_inboard_outer (float): WP inboard outer radius [m] - r_tf_wp_inboard_centre (float): WP inboard centre radius [m] - dx_tf_wp_toroidal_min (float): Minimal toroidal thickness of WP [m] - dr_tf_wp_no_insulation (float): Radial thickness of winding pack without insulation [m] - dx_tf_wp_primary_toroidal (float): Primary toroidal thickness [m] - dx_tf_wp_secondary_toroidal (float): Secondary toroidal thickness [m] - dx_tf_wp_toroidal_average (float): Averaged toroidal thickness [m] - a_tf_wp_with_insulation (float): WP cross-sectional area with insulation [m²] - a_tf_wp_no_insulation (float): WP cross-sectional area without insulation [m²] - a_tf_wp_ground_insulation (float): WP ground insulation cross-sectional area [m²]

Raises:

Type Description
ValueError

If calculated winding pack area (with or without insulation) is non-positive.

Source code in process/models/tfcoil/superconducting.py
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
def superconducting_tf_wp_geometry(
    self,
    i_tf_wp_geom: int,
    r_tf_inboard_in: float,
    dr_tf_nose_case: float,
    dr_tf_wp_with_insulation: float,
    tan_theta_coil: float,
    dx_tf_side_case_min: float,
    dx_tf_wp_insulation: float,
    dx_tf_wp_insertion_gap: float,
) -> tuple[
    float,  # r_tf_wp_inboard_inner
    float,  # r_tf_wp_inboard_outer
    float,  # r_tf_wp_inboard_centre
    float,  # dx_tf_wp_toroidal_min
    float,  # dr_tf_wp_no_insulation
    float,  # dx_tf_wp_primary_toroidal
    float,  # dx_tf_wp_secondary_toroidal
    float,  # dx_tf_wp_toroidal_average
    float,  # a_tf_wp_with_insulation
    float,  # a_tf_wp_no_insulation
    float,  # a_tf_wp_ground_insulation
]:
    """Calculates the winding pack (WP) geometry and cross-sectional areas for superconducting toroidal field (TF) coils.

    Parameters
    ----------
    i_tf_wp_geom : int
        0: Rectangular
        - 1: Double rectangular
        - 2: Trapezoidal
    r_tf_inboard_in : float
        Inboard inner radius [m].
    dr_tf_nose_case : float
        Radial thickness of nose case [m].
    dr_tf_wp_with_insulation : float
        Radial thickness of winding pack including insulation [m].
    tan_theta_coil : float
        Tangent of coil half angle [-].
    dx_tf_side_case_min : float
        Side case thickness [m].
    dx_tf_wp_insulation : float
        Insulation thickness [m].
    dx_tf_wp_insertion_gap : float
        Insertion gap thickness [m].

    Returns
    -------
    tuple[float, float, float, float, float, float, float, float, float, float]
        Tuple containing:
        - r_tf_wp_inboard_inner (float): WP inboard inner radius [m]
        - r_tf_wp_inboard_outer (float): WP inboard outer radius [m]
        - r_tf_wp_inboard_centre (float): WP inboard centre radius [m]
        - dx_tf_wp_toroidal_min (float): Minimal toroidal thickness of WP [m]
        - dr_tf_wp_no_insulation (float): Radial thickness of winding pack without insulation [m]
        - dx_tf_wp_primary_toroidal (float): Primary toroidal thickness [m]
        - dx_tf_wp_secondary_toroidal (float): Secondary toroidal thickness [m]
        - dx_tf_wp_toroidal_average (float): Averaged toroidal thickness [m]
        - a_tf_wp_with_insulation (float): WP cross-sectional area with insulation [m²]
        - a_tf_wp_no_insulation (float): WP cross-sectional area without insulation [m²]
        - a_tf_wp_ground_insulation (float): WP ground insulation cross-sectional area [m²]

    Raises
    ------
    ValueError
        If calculated winding pack area (with or without insulation) is non-positive.
    """

    r_tf_wp_inboard_inner = r_tf_inboard_in + dr_tf_nose_case

    # Radial position of outer edge of winding pack [m]
    r_tf_wp_inboard_outer = r_tf_wp_inboard_inner + dr_tf_wp_with_insulation

    # Radius of geometrical centre of winding pack [m]
    r_tf_wp_inboard_centre = 0.5e0 * (r_tf_wp_inboard_inner + r_tf_wp_inboard_outer)

    # TF toroidal thickness at the WP inner radius [m]
    dx_tf_wp_inner_toroidal = 2.0e0 * r_tf_wp_inboard_inner * tan_theta_coil

    # Minimal toroidal thickness of winding pack [m]
    dx_tf_wp_toroidal_min = dx_tf_wp_inner_toroidal - 2.0e0 * dx_tf_side_case_min

    # Radial thickness of winding pack without insulation (e.g. the conductor region) [m]
    dr_tf_wp_no_insulation = dr_tf_wp_with_insulation - 2.0e0 * (
        dx_tf_wp_insulation + dx_tf_wp_insertion_gap
    )

    # Rectangular WP
    # --------------
    if i_tf_wp_geom == 0:
        # Outer WP layer toroidal thickness [m]
        dx_tf_wp_primary_toroidal = dx_tf_wp_toroidal_min

        # No secondary WP here but will set for consistency
        dx_tf_wp_secondary_toroidal = dx_tf_wp_toroidal_min

        # Averaged toroidal thickness of of winding pack [m]
        dx_tf_wp_toroidal_average = dx_tf_wp_toroidal_min

        # Total cross-sectional area of winding pack [m²]
        a_tf_wp_with_insulation = (
            dr_tf_wp_with_insulation * dx_tf_wp_primary_toroidal
        )

        # WP cross-section without insertion gap and ground insulation [m²]
        a_tf_wp_no_insulation = (
            dr_tf_wp_with_insulation
            - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
        ) * (
            dx_tf_wp_primary_toroidal
            - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
        )

        # Cross-section area of the WP ground insulation [m²]
        a_tf_wp_ground_insulation = (
            dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap
        ) * (
            dx_tf_wp_primary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap
        ) - a_tf_wp_no_insulation

    # Double rectangular WP
    # ---------------------
    elif i_tf_wp_geom == 1:
        # Thickness of winding pack section at R > superconducting_tf_coil_variables.r_tf_wp_inboard_centre [m]
        dx_tf_wp_primary_toroidal = 2.0e0 * (
            r_tf_wp_inboard_centre * tan_theta_coil - dx_tf_side_case_min
        )

        # Thickness of winding pack section at R < superconducting_tf_coil_variables.r_tf_wp_inboard_centre [m]
        dx_tf_wp_secondary_toroidal = 2.0e0 * (
            r_tf_wp_inboard_inner * tan_theta_coil - dx_tf_side_case_min
        )

        # Averaged toroidal thickness of of winding pack [m]
        dx_tf_wp_toroidal_average = 0.5e0 * (
            dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal
        )

        # Total cross-sectional area of winding pack [m²]
        # Including ground insulation and insertion gap
        a_tf_wp_with_insulation = (
            dr_tf_wp_with_insulation * dx_tf_wp_toroidal_average
        )

        # WP cross-section without insertion gap and ground insulation [m²]
        a_tf_wp_no_insulation = (
            0.5e0
            * (
                dr_tf_wp_with_insulation
                - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
            )
            * (
                dx_tf_wp_primary_toroidal
                + dx_tf_wp_secondary_toroidal
                - 4.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
            )
        )

        # Cross-section area of the WP ground insulation [m²]
        a_tf_wp_ground_insulation = (
            0.5e0
            * (dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap)
            * (
                dx_tf_wp_primary_toroidal
                + dx_tf_wp_secondary_toroidal
                - 4.0e0 * dx_tf_wp_insertion_gap
            )
            - a_tf_wp_no_insulation
        )

    # Trapezoidal WP
    # --------------
    else:
        # Thickness of winding pack section at r_tf_wp_inboard_outer [m]
        dx_tf_wp_primary_toroidal = 2.0e0 * (
            r_tf_wp_inboard_outer * tan_theta_coil - dx_tf_side_case_min
        )

        # Thickness of winding pack section at r_tf_wp_inboard_inner [m]
        dx_tf_wp_secondary_toroidal = 2.0e0 * (
            r_tf_wp_inboard_inner * tan_theta_coil - dx_tf_side_case_min
        )

        # Averaged toroidal thickness of of winding pack [m]
        dx_tf_wp_toroidal_average = 0.5e0 * (
            dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal
        )

        # Total cross-sectional area of winding pack [m²]
        # Including ground insulation and insertion gap
        a_tf_wp_with_insulation = (
            dr_tf_wp_with_insulation
            * 0.5
            * (dx_tf_wp_primary_toroidal + dx_tf_wp_secondary_toroidal)
        )

        # WP cross-section without insertion gap and ground insulation [m²]
        a_tf_wp_no_insulation = (
            (
                dr_tf_wp_with_insulation
                - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
            )
            * (
                (
                    dx_tf_wp_secondary_toroidal
                    - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                )
                + (
                    dx_tf_wp_primary_toroidal
                    - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
                )
            )
            / 2
        )

        # Cross-section area of the WP ground insulation [m²]
        a_tf_wp_ground_insulation = (
            dr_tf_wp_with_insulation - 2.0e0 * dx_tf_wp_insertion_gap
        ) * (
            (
                (dx_tf_wp_primary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap)
                + (dx_tf_wp_secondary_toroidal - 2.0e0 * dx_tf_wp_insertion_gap)
            )
            / 2
        ) - a_tf_wp_no_insulation

    # --------------
    # Negative WP area error reporting
    if a_tf_wp_no_insulation <= 0.0e0 or a_tf_wp_with_insulation <= 0.0e0:
        logger.error(
            f"Winding pack cross-section problem... {a_tf_wp_no_insulation=} {a_tf_wp_with_insulation=}"
        )

    return (
        r_tf_wp_inboard_inner,
        r_tf_wp_inboard_outer,
        r_tf_wp_inboard_centre,
        dx_tf_wp_toroidal_min,
        dr_tf_wp_no_insulation,
        dx_tf_wp_primary_toroidal,
        dx_tf_wp_secondary_toroidal,
        dx_tf_wp_toroidal_average,
        a_tf_wp_with_insulation,
        a_tf_wp_no_insulation,
        a_tf_wp_ground_insulation,
    )

superconducting_tf_case_geometry(i_tf_wp_geom, i_tf_case_geom, a_tf_inboard_total, n_tf_coils, a_tf_wp_with_insulation, a_tf_leg_outboard, rad_tf_coil_inboard_toroidal_half, r_tf_inboard_out, tan_theta_coil, r_tf_wp_inboard_outer, dr_tf_plasma_case, r_tf_wp_inboard_inner, r_tf_inboard_in, dx_tf_side_case_min, dr_tf_wp_with_insulation)

Setting the case geometry and area for SC magnets

Parameters:

Name Type Description Default
i_tf_wp_geom int

Index specifying winding pack geometry (0: rectangular, 1: double rectangular, else: trapezoidal).

required
i_tf_case_geom int

Index specifying case geometry (0: circular, else: straight).

required
a_tf_inboard_total float

Total inboard area for TF coils [m²].

required
n_tf_coils float

Number of TF coils.

required
a_tf_wp_with_insulation float

Area of winding pack with insulation [m²].

required
a_tf_leg_outboard float

Outboard leg cross-sectional area [m²].

required
rad_tf_coil_inboard_toroidal_half float

Half toroidal radius of inboard coil [m].

required
r_tf_inboard_out float

Outer radius of inboard TF coil [m].

required
tan_theta_coil float

Tangent of coil angle theta.

required
r_tf_wp_inboard_outer float

Outer radius of inboard winding pack [m].

required
dr_tf_plasma_case float

Radial thickness of plasma case [m].

required
r_tf_wp_inboard_inner float

Inner radius of inboard winding pack [m].

required
r_tf_inboard_in float

Inner radius of inboard TF coil [m].

required
dx_tf_side_case_min float

Minimum lateral casing thickness [m].

required
dr_tf_wp_with_insulation float

Radial thickness of winding pack with insulation [m].

required

Returns:

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

Tuple containing: - a_tf_coil_inboard_case (float): Inboard case area [m²]. - a_tf_coil_outboard_case (float): Outboard case area [m²]. - a_tf_plasma_case (float): Front casing area [m²]. - a_tf_coil_nose_case (float): Nose casing area [m²]. - dx_tf_side_case_average (float): Average lateral casing thickness [m]. - dx_tf_side_case_peak (float): Peak lateral casing thickness [m].

Source code in process/models/tfcoil/superconducting.py
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
def superconducting_tf_case_geometry(
    self,
    i_tf_wp_geom: int,
    i_tf_case_geom: int,
    a_tf_inboard_total: float,
    n_tf_coils: float,
    a_tf_wp_with_insulation: float,
    a_tf_leg_outboard: float,
    rad_tf_coil_inboard_toroidal_half: float,
    r_tf_inboard_out: float,
    tan_theta_coil: float,
    r_tf_wp_inboard_outer: float,
    dr_tf_plasma_case: float,
    r_tf_wp_inboard_inner: float,
    r_tf_inboard_in: float,
    dx_tf_side_case_min: float,
    dr_tf_wp_with_insulation: float,
) -> tuple[float, float, float, float, float, float]:
    """Setting the case geometry and area for SC magnets

    Parameters
    ----------
    i_tf_wp_geom : int
        Index specifying winding pack geometry (0: rectangular, 1: double rectangular, else: trapezoidal).
    i_tf_case_geom : int
        Index specifying case geometry (0: circular, else: straight).
    a_tf_inboard_total : float
        Total inboard area for TF coils [m²].
    n_tf_coils : float
        Number of TF coils.
    a_tf_wp_with_insulation : float
        Area of winding pack with insulation [m²].
    a_tf_leg_outboard : float
        Outboard leg cross-sectional area [m²].
    rad_tf_coil_inboard_toroidal_half : float
        Half toroidal radius of inboard coil [m].
    r_tf_inboard_out : float
        Outer radius of inboard TF coil [m].
    tan_theta_coil : float
        Tangent of coil angle theta.
    r_tf_wp_inboard_outer : float
        Outer radius of inboard winding pack [m].
    dr_tf_plasma_case : float
        Radial thickness of plasma case [m].
    r_tf_wp_inboard_inner : float
        Inner radius of inboard winding pack [m].
    r_tf_inboard_in : float
        Inner radius of inboard TF coil [m].
    dx_tf_side_case_min : float
        Minimum lateral casing thickness [m].
    dr_tf_wp_with_insulation : float
        Radial thickness of winding pack with insulation [m].

    Returns
    -------
    tuple[float, float, float, float, float]
        Tuple containing:
        - a_tf_coil_inboard_case (float): Inboard case area [m²].
        - a_tf_coil_outboard_case (float): Outboard case area [m²].
        - a_tf_plasma_case (float): Front casing area [m²].
        - a_tf_coil_nose_case (float): Nose casing area [m²].
        - dx_tf_side_case_average (float): Average lateral casing thickness [m].
        - dx_tf_side_case_peak (float): Peak lateral casing thickness [m].
    """

    # Total area of inboard TF coil case [m²]
    a_tf_coil_inboard_case = (
        a_tf_inboard_total / n_tf_coils
    ) - a_tf_wp_with_insulation

    # Outboard leg cross-sectional area of surrounding case [m²]
    a_tf_coil_outboard_case = a_tf_leg_outboard - a_tf_wp_with_insulation

    # Front casing area [m²]
    if i_tf_case_geom == 0:
        # Circular front case
        a_tf_plasma_case = (
            rad_tf_coil_inboard_toroidal_half * r_tf_inboard_out**2
        ) - (tan_theta_coil * r_tf_wp_inboard_outer**2)
    else:
        # Straight front case [m²]
        a_tf_plasma_case = (
            (r_tf_wp_inboard_outer + dr_tf_plasma_case) ** 2
            - r_tf_wp_inboard_outer**2
        ) * tan_theta_coil

    # Nose casing area [m²]
    a_tf_coil_nose_case = (
        tan_theta_coil * r_tf_wp_inboard_inner**2
        - rad_tf_coil_inboard_toroidal_half * r_tf_inboard_in**2
    )

    # Report error if the casing area is negative
    if a_tf_coil_inboard_case <= 0.0e0 or a_tf_coil_outboard_case <= 0.0e0:
        logger.error(
            f"Winding pack cross-section problem... {a_tf_coil_inboard_case=} {a_tf_coil_outboard_case=}"
        )

    # Average lateral casing thickness [m]
    # --------------
    # Rectangular casing
    if i_tf_wp_geom == 0:
        dx_tf_side_case_average = (
            dx_tf_side_case_min + 0.5e0 * tan_theta_coil * dr_tf_wp_with_insulation
        )

    # Double rectangular WP
    elif i_tf_wp_geom == 1:
        dx_tf_side_case_average = (
            dx_tf_side_case_min + 0.25e0 * tan_theta_coil * dr_tf_wp_with_insulation
        )

    # Trapezoidal WP
    else:
        dx_tf_side_case_average = dx_tf_side_case_min

    # Peak lateral casing thickness [m]
    # --------------
    # Rectangular casing

    if i_tf_wp_geom == 0:
        dx_tf_side_case_peak = (
            dx_tf_side_case_min + tan_theta_coil * dr_tf_wp_with_insulation
        )
    # Double rectangular WP
    elif i_tf_wp_geom == 1:
        dx_tf_side_case_peak = (
            dx_tf_side_case_min + 0.5 * tan_theta_coil * dr_tf_wp_with_insulation
        )

    # Trapezoidal WP
    # Constant thickness so min = average
    else:
        dx_tf_side_case_peak = dx_tf_side_case_min

    return (
        a_tf_coil_inboard_case,
        a_tf_coil_outboard_case,
        a_tf_plasma_case,
        a_tf_coil_nose_case,
        dx_tf_side_case_average,
        dx_tf_side_case_peak,
    )

tf_cable_in_conduit_integer_turn_geometry(dr_tf_wp_with_insulation, dx_tf_wp_insulation, dx_tf_wp_insertion_gap, n_tf_wp_layers, dx_tf_wp_toroidal_min, n_tf_wp_pancakes, c_tf_coil, dx_tf_turn_steel, dx_tf_turn_insulation)

Set the TF WP turn geometry for superconducting magnets using the number of turn rows in the radial direction. The turns can have any rectangular shape.

This calculation checks if a turn can exist (positive cable space) and provides its dimensions, areas, and associated current.

Parameters:

Name Type Description Default
dr_tf_wp_with_insulation float

Radial thickness of winding pack with insulation [m].

required
dx_tf_wp_insulation float

Thickness of winding pack insulation [m].

required
dx_tf_wp_insertion_gap float

Thickness of winding pack insertion gap [m].

required
n_tf_wp_layers int

Number of winding pack layers (radial direction).

required
dx_tf_wp_toroidal_min float

Minimum toroidal thickness of winding pack [m].

required
n_tf_wp_pancakes int

Number of winding pack pancakes (toroidal direction).

required
c_tf_coil float

Total TF coil current [A].

required
dx_tf_turn_steel float

Thickness of turn steel [m].

required
dx_tf_turn_insulation float

Thickness of turn insulation [m].

required

Returns:

Type Description
type

tuple containing: - radius_tf_turn_cable_space_corners - dr_tf_turn - dx_tf_turn - a_tf_turn_cable_space_no_void - a_tf_turn_steel - a_tf_turn_insulation - c_tf_turn - n_tf_coil_turns - t_conductor_radial - t_conductor_toroidal - t_conductor - dr_tf_turn_cable_space - dx_tf_turn_cable_space - dx_tf_turn_cable_space_average

Source code in process/models/tfcoil/superconducting.py
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
def tf_cable_in_conduit_integer_turn_geometry(
    self,
    dr_tf_wp_with_insulation: float,
    dx_tf_wp_insulation: float,
    dx_tf_wp_insertion_gap: float,
    n_tf_wp_layers: int,
    dx_tf_wp_toroidal_min: float,
    n_tf_wp_pancakes: int,
    c_tf_coil: float,
    dx_tf_turn_steel: float,
    dx_tf_turn_insulation: float,
) -> tuple[
    float,  # radius_tf_turn_cable_space_corners
    float,  # dr_tf_turn
    float,  # dx_tf_turn
    float,  # a_tf_turn_cable_space_no_void
    float,  # a_tf_turn_steel
    float,  # a_tf_turn_insulation
    float,  # c_tf_turn
    float,  # n_tf_coil_turns
    float,  # t_conductor_radial
    float,  # t_conductor_toroidal
    float,  # t_conductor
    float,  # dr_tf_turn_cable_space
    float,  # dx_tf_turn_cable_space
    float,  # dx_tf_turn_cable_space_average
]:
    """Set the TF WP turn geometry for superconducting magnets using the number of turn rows in the radial direction.
    The turns can have any rectangular shape.

    This calculation checks if a turn can exist (positive cable space) and provides its dimensions, areas, and associated current.

    Parameters
    ----------
    dr_tf_wp_with_insulation : float
        Radial thickness of winding pack with insulation [m].
    dx_tf_wp_insulation : float
        Thickness of winding pack insulation [m].
    dx_tf_wp_insertion_gap : float
        Thickness of winding pack insertion gap [m].
    n_tf_wp_layers : int
        Number of winding pack layers (radial direction).
    dx_tf_wp_toroidal_min : float
        Minimum toroidal thickness of winding pack [m].
    n_tf_wp_pancakes : int
        Number of winding pack pancakes (toroidal direction).
    c_tf_coil : float
        Total TF coil current [A].
    dx_tf_turn_steel : float
        Thickness of turn steel [m].
    dx_tf_turn_insulation : float
        Thickness of turn insulation [m].

    Returns
    -------
    type
        tuple containing:
        - radius_tf_turn_cable_space_corners
        - dr_tf_turn
        - dx_tf_turn
        - a_tf_turn_cable_space_no_void
        - a_tf_turn_steel
        - a_tf_turn_insulation
        - c_tf_turn
        - n_tf_coil_turns
        - t_conductor_radial
        - t_conductor_toroidal
        - t_conductor
        - dr_tf_turn_cable_space
        - dx_tf_turn_cable_space
        - dx_tf_turn_cable_space_average
    """

    # Radius of rounded corners in the cable space [m]
    radius_tf_turn_cable_space_corners = dx_tf_turn_steel * 0.75e0

    # Radial turn dimension [m]
    dr_tf_turn = (
        dr_tf_wp_with_insulation
        - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
    ) / n_tf_wp_layers

    if dr_tf_turn <= (2.0e0 * dx_tf_turn_insulation + 2.0e0 * dx_tf_turn_steel):
        logger.error(
            "Negative cable space dimension; reduce conduit thicknesses or raise c_tf_turn. "
            f"{dr_tf_turn=} {dx_tf_turn_insulation=} {dx_tf_turn_steel=}"
        )

    # Toroidal turn dimension [m]
    dx_tf_turn = (
        dx_tf_wp_toroidal_min
        - 2.0e0 * (dx_tf_wp_insulation + dx_tf_wp_insertion_gap)
    ) / n_tf_wp_pancakes

    if dx_tf_turn <= (2.0e0 * dx_tf_turn_insulation + 2.0e0 * dx_tf_turn_steel):
        logger.error(
            "Negative cable space dimension; reduce conduit thicknesses or raise c_tf_turn. "
            f"{dx_tf_turn=} {dx_tf_turn_insulation=} {dx_tf_turn_steel=}"
        )

    # Average turn dimension [m]
    tfcoil_variables.dx_tf_turn_general = np.sqrt(dr_tf_turn * dx_tf_turn)

    # Number of TF turns
    n_tf_coil_turns = np.double(n_tf_wp_layers * n_tf_wp_pancakes)

    # Current per turn [A/turn]
    c_tf_turn = c_tf_coil / n_tf_coil_turns

    # Radial and toroidal dimension of conductor [m]
    t_conductor_radial = dr_tf_turn - 2.0e0 * dx_tf_turn_insulation
    t_conductor_toroidal = dx_tf_turn - 2.0e0 * dx_tf_turn_insulation
    t_conductor = np.sqrt(t_conductor_radial * t_conductor_toroidal)

    # Dimension of square cable space inside conduit [m]
    dr_tf_turn_cable_space = t_conductor_radial - 2.0e0 * dx_tf_turn_steel
    dx_tf_turn_cable_space = t_conductor_toroidal - 2.0e0 * dx_tf_turn_steel
    dx_tf_turn_cable_space_average = np.sqrt(
        dr_tf_turn_cable_space * dx_tf_turn_cable_space
    )

    # Cross-sectional area of cable space per turn
    # taking account of rounded inside corners [m²]
    a_tf_turn_cable_space_no_void = (
        dr_tf_turn_cable_space * dx_tf_turn_cable_space
    ) - (4.0e0 - np.pi) * radius_tf_turn_cable_space_corners**2

    # Calculate the true effective cable space by taking away the cooling
    # channel and the extra void fraction
    superconducting_tf_coil_variables.a_tf_turn_cable_space_effective = (
        a_tf_turn_cable_space_no_void
        -
        # Coolant channel area
        (
            (np.pi / 4.0e0)
            * tfcoil_variables.dia_tf_turn_coolant_channel
            * tfcoil_variables.dia_tf_turn_coolant_channel
        )
        # Additional void area deduction
        - (
            a_tf_turn_cable_space_no_void
            * tfcoil_variables.f_a_tf_turn_cable_space_extra_void
        )
    )

    superconducting_tf_coil_variables.f_a_tf_turn_cable_space_cooling = 1 - (
        superconducting_tf_coil_variables.a_tf_turn_cable_space_effective
        / a_tf_turn_cable_space_no_void
    )

    if a_tf_turn_cable_space_no_void <= 0.0e0:
        if (dr_tf_turn_cable_space < 0.0e0) or (dx_tf_turn_cable_space < 0.0e0):
            logger.error(
                f"Negative cable space dimension. {a_tf_turn_cable_space_no_void=} "
                f"{dr_tf_turn_cable_space=} {dx_tf_turn_cable_space=}"
            )
        else:
            logger.error(
                "Cable space area problem; artificially set rounded corner radius to 0. "
                f"{a_tf_turn_cable_space_no_void=} {dr_tf_turn_cable_space=}"
                f" {dx_tf_turn_cable_space=}"
            )
            radius_tf_turn_cable_space_corners = 0.0e0
            a_tf_turn_cable_space_no_void = (
                dr_tf_turn_cable_space * dx_tf_turn_cable_space
            )

    # Cross-sectional area of conduit jacket per turn [m²]
    a_tf_turn_steel = (
        t_conductor_radial * t_conductor_toroidal - a_tf_turn_cable_space_no_void
    )

    # Area of inter-turn insulation: single turn [m²]
    a_tf_turn_insulation = (
        dr_tf_turn * dx_tf_turn - a_tf_turn_steel - a_tf_turn_cable_space_no_void
    )
    return (
        radius_tf_turn_cable_space_corners,
        dr_tf_turn,
        dx_tf_turn,
        a_tf_turn_cable_space_no_void,
        a_tf_turn_steel,
        a_tf_turn_insulation,
        c_tf_turn,
        n_tf_coil_turns,
        t_conductor_radial,
        t_conductor_toroidal,
        t_conductor,
        dr_tf_turn_cable_space,
        dx_tf_turn_cable_space,
        dx_tf_turn_cable_space_average,
    )

tf_wp_currents()

Turn engineering turn currents/densities

Source code in process/models/tfcoil/superconducting.py
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
def tf_wp_currents(self):
    """
    Turn engineering turn currents/densities
    """
    tfcoil_variables.j_tf_wp = max(
        1.0e0,
        tfcoil_variables.c_tf_total
        / (
            tfcoil_variables.n_tf_coils
            * superconducting_tf_coil_variables.a_tf_wp_no_insulation
        ),
    )

tf_cable_in_conduit_averaged_turn_geometry(j_tf_wp, dx_tf_turn_steel, dx_tf_turn_insulation, i_tf_sc_mat, dx_tf_turn_general, c_tf_turn, i_dx_tf_turn_general_input, i_dx_tf_turn_cable_space_general_input, dx_tf_turn_cable_space_general, layer_ins, a_tf_wp_no_insulation, dia_tf_turn_coolant_channel, f_a_tf_turn_cable_space_extra_void)

subroutine straight from Python, see comments in tf_averaged_turn_geom_wrapper Setting the TF WP turn geometry for SC magnets from the number the current per turn. This calculation has two purposes, first to check if a turn can exist (positive cable space) and the second to provide its dimensions, areas and the (float) number of turns

Parameters:

Name Type Description Default
j_tf_wp
required
dx_tf_turn_steel
required
dx_tf_turn_insulation
required
i_tf_sc_mat
required
dx_tf_turn_general
required
c_tf_turn
required
i_dx_tf_turn_general_input
required
i_dx_tf_turn_cable_space_general_input
required
dx_tf_turn_cable_space_general
required
layer_ins
required
a_tf_wp_no_insulation
required
dia_tf_turn_coolant_channel
required
f_a_tf_turn_cable_space_extra_void
required
Source code in process/models/tfcoil/superconducting.py
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
def tf_cable_in_conduit_averaged_turn_geometry(
    self,
    j_tf_wp,
    dx_tf_turn_steel,
    dx_tf_turn_insulation,
    i_tf_sc_mat,
    dx_tf_turn_general,
    c_tf_turn,
    i_dx_tf_turn_general_input,
    i_dx_tf_turn_cable_space_general_input,
    dx_tf_turn_cable_space_general,
    layer_ins,
    a_tf_wp_no_insulation,
    dia_tf_turn_coolant_channel,
    f_a_tf_turn_cable_space_extra_void,
):
    """subroutine straight from Python, see comments in tf_averaged_turn_geom_wrapper
    Setting the TF WP turn geometry for SC magnets from the number
    the current per turn.
    This calculation has two purposes, first to check if a turn can exist
    (positive cable space) and the second to provide its dimensions,
    areas and the (float) number of turns

    Parameters
    ----------
    j_tf_wp :

    dx_tf_turn_steel :

    dx_tf_turn_insulation :

    i_tf_sc_mat :

    dx_tf_turn_general :

    c_tf_turn :

    i_dx_tf_turn_general_input :

    i_dx_tf_turn_cable_space_general_input :

    dx_tf_turn_cable_space_general :

    layer_ins :

    a_tf_wp_no_insulation :

    dia_tf_turn_coolant_channel :

    f_a_tf_turn_cable_space_extra_void :

    """

    # Turn dimension is a an input
    if i_dx_tf_turn_general_input:
        # Turn area [m2]
        a_tf_turn = dx_tf_turn_general**2

        # Current per turn [A]
        c_tf_turn = a_tf_turn * j_tf_wp

    # Turn cable dimension is an input
    elif i_dx_tf_turn_cable_space_general_input:
        # Turn squared dimension [m]
        dx_tf_turn_general = dx_tf_turn_cable_space_general + 2.0e0 * (
            dx_tf_turn_insulation + dx_tf_turn_steel
        )

        # Turn area [m2]
        a_tf_turn = dx_tf_turn_general**2

        # Current per turn [A]
        c_tf_turn = a_tf_turn * j_tf_wp

    # Current per turn is an input
    else:
        # Turn area [m2]
        # Allow for additional inter-layer insulation MDK 13/11/18
        # Area of turn including conduit and inter-layer insulation
        a_tf_turn = c_tf_turn / j_tf_wp

        # Dimension of square cross-section of each turn including inter-turn insulation [m]
        dx_tf_turn_general = np.sqrt(a_tf_turn)

    # Square turn assumption
    dr_tf_turn = dx_tf_turn_general
    dx_tf_turn = dx_tf_turn_general

    # See derivation in the following document
    # k:\power plant physics and technology\process\hts\hts coil module for process.docx
    t_conductor = (
        -layer_ins + np.sqrt(layer_ins**2 + 4.0e00 * a_tf_turn)
    ) / 2 - 2.0e0 * dx_tf_turn_insulation

    # Total number of turns per TF coil (not required to be an integer)
    n_tf_coil_turns = a_tf_wp_no_insulation / a_tf_turn

    # Area of inter-turn insulation: single turn [m2]
    a_tf_turn_insulation = a_tf_turn - t_conductor**2

    # NOTE: Fortran has a_tf_turn_cable_space_no_void as an intent(out) variable that was outputting
    # into tfcoil_variables.a_tf_turn_cable_space_no_void. The local variable, however, appears to
    # initially hold the value of tfcoil_variables.a_tf_turn_cable_space_no_void despite not being
    # intent(in). I have replicated this behaviour in Python for now.
    a_tf_turn_cable_space_no_void = copy.copy(
        tfcoil_variables.a_tf_turn_cable_space_no_void
    )

    # ITER like turn structure
    if i_tf_sc_mat != 6:
        # Radius of rounded corners of cable space inside conduit [m]
        radius_tf_turn_cable_space_corners = dx_tf_turn_steel * 0.75e0

        # Dimension of square cable space inside conduit [m]
        dx_tf_turn_cable_space_average = t_conductor - 2.0e0 * dx_tf_turn_steel

        # Cross-sectional area of cable space per turn
        # taking account of rounded inside corners [m2]
        a_tf_turn_cable_space_no_void = (
            dx_tf_turn_cable_space_average**2
            - (4.0e0 - np.pi) * radius_tf_turn_cable_space_corners**2
        )

        # Calculate the true effective cable space by taking away the cooling
        # channel and the extra void fraction

        a_tf_turn_cable_space_effective = (
            a_tf_turn_cable_space_no_void
            -
            # Coolant channel area
            (
                (np.pi / 4.0e0)
                * dia_tf_turn_coolant_channel
                * dia_tf_turn_coolant_channel
            )
            # Additional void area deduction
            - (a_tf_turn_cable_space_no_void * f_a_tf_turn_cable_space_extra_void)
        )

        f_a_tf_turn_cable_space_cooling = 1 - (
            a_tf_turn_cable_space_effective / a_tf_turn_cable_space_no_void
        )

        if a_tf_turn_cable_space_no_void <= 0.0e0:
            if t_conductor < 0.0e0:
                logger.error(
                    f"Negative cable space dimension. {a_tf_turn_cable_space_no_void=} "
                    f"{dx_tf_turn_cable_space_average=}"
                )
            else:
                logger.error(
                    "Cable space area problem; artificially set rounded corner radius to 0. "
                    f"{a_tf_turn_cable_space_no_void=} {dx_tf_turn_cable_space_average=}"
                )
                radius_tf_turn_cable_space_corners = 0.0e0
                a_tf_turn_cable_space_no_void = dx_tf_turn_cable_space_average**2

        # Cross-sectional area of conduit jacket per turn [m2]
        a_tf_turn_steel = t_conductor**2 - a_tf_turn_cable_space_no_void

    # REBCO turn structure
    elif i_tf_sc_mat == 6:
        # Diameter of circular cable space inside conduit [m]
        dx_tf_turn_cable_space_average = t_conductor - 2.0e0 * dx_tf_turn_steel

        # Cross-sectional area of conduit jacket per turn [m2]
        a_tf_turn_steel = t_conductor**2 - a_tf_turn_cable_space_no_void

    return (
        a_tf_turn_cable_space_no_void,
        a_tf_turn_steel,
        a_tf_turn_insulation,
        n_tf_coil_turns,
        dx_tf_turn_general,
        c_tf_turn,
        dx_tf_turn_general,
        dr_tf_turn,
        dx_tf_turn,
        t_conductor,
        radius_tf_turn_cable_space_corners,
        dx_tf_turn_cable_space_average,
        a_tf_turn_cable_space_effective,
        f_a_tf_turn_cable_space_cooling,
    )

superconducting_tf_coil_areas_and_masses()

Source code in process/models/tfcoil/superconducting.py
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
def superconducting_tf_coil_areas_and_masses(self):
    # Mass of case [kg]
    # ***

    # Mass of ground-wall insulation [kg]
    # (assumed to be same density/material as turn insulation)
    tfcoil_variables.m_tf_coil_wp_insulation = (
        tfcoil_variables.len_tf_coil
        * (
            superconducting_tf_coil_variables.a_tf_wp_with_insulation
            - superconducting_tf_coil_variables.a_tf_wp_no_insulation
        )
        * tfcoil_variables.den_tf_wp_turn_insulation
    )

    # The length of the vertical section is that of the first (inboard) segment
    # = height of TF coil inner edge + (2 * coil thickness)
    tfcoil_variables.cplen = (2.0e0 * build_variables.z_tf_inside_half) + (
        2.0e0 * build_variables.dr_tf_inboard
    )

    # The 2.2 factor is used as a scaling factor to fit
    # to the ITER-FDR value of 450 tonnes; see CCFE note T&M/PKNIGHT/PROCESS/026
    if physics_variables.itart == 1:
        # tfcoil_variables.len_tf_coil does not include inboard leg ('centrepost') length in TART
        tfcoil_variables.m_tf_coil_case = (
            2.2e0
            * tfcoil_variables.den_tf_coil_case
            * (
                tfcoil_variables.cplen * tfcoil_variables.a_tf_coil_inboard_case
                + tfcoil_variables.len_tf_coil
                * tfcoil_variables.a_tf_coil_outboard_case
            )
        )
    else:
        tfcoil_variables.m_tf_coil_case = (
            2.2e0
            * tfcoil_variables.den_tf_coil_case
            * (
                tfcoil_variables.cplen * tfcoil_variables.a_tf_coil_inboard_case
                + (tfcoil_variables.len_tf_coil - tfcoil_variables.cplen)
                * tfcoil_variables.a_tf_coil_outboard_case
            )
        )

    # ***

    # Masses of conductor constituents
    # ---------------------------------
    # Superconductor mass [kg]
    # Includes space allowance for central helium channel, area tfcoil_variables.a_tf_wp_coolant_channels
    tfcoil_variables.m_tf_coil_superconductor = (
        tfcoil_variables.len_tf_coil
        * tfcoil_variables.n_tf_coil_turns
        * tfcoil_variables.a_tf_turn_cable_space_no_void
        * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
        * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_copper)
        - tfcoil_variables.len_tf_coil * tfcoil_variables.a_tf_wp_coolant_channels
    ) * tfcoil_variables.dcond[tfcoil_variables.i_tf_sc_mat - 1]

    # Copper mass [kg]
    tfcoil_variables.m_tf_coil_copper = (
        tfcoil_variables.len_tf_coil
        * tfcoil_variables.n_tf_coil_turns
        * tfcoil_variables.a_tf_turn_cable_space_no_void
        * (1.0e0 - tfcoil_variables.f_a_tf_turn_cable_space_extra_void)
        * tfcoil_variables.f_a_tf_turn_cable_copper
        - tfcoil_variables.len_tf_coil * tfcoil_variables.a_tf_wp_coolant_channels
    ) * constants.den_copper
    if tfcoil_variables.m_tf_coil_copper <= 0.0e0:
        tfcoil_variables.m_tf_coil_copper = 0.0e0

    # Steel conduit (sheath) mass [kg]
    tfcoil_variables.m_tf_wp_steel_conduit = (
        tfcoil_variables.len_tf_coil
        * tfcoil_variables.n_tf_coil_turns
        * tfcoil_variables.a_tf_turn_steel
        * fwbs_variables.den_steel
    )

    # Conduit insulation mass [kg]
    # (tfcoil_variables.a_tf_coil_wp_turn_insulation already contains tfcoil_variables.n_tf_coil_turns)
    tfcoil_variables.m_tf_coil_wp_turn_insulation = (
        tfcoil_variables.len_tf_coil
        * tfcoil_variables.a_tf_coil_wp_turn_insulation
        * tfcoil_variables.den_tf_wp_turn_insulation
    )

    # Total conductor mass [kg]
    tfcoil_variables.m_tf_coil_conductor = (
        tfcoil_variables.m_tf_coil_superconductor
        + tfcoil_variables.m_tf_coil_copper
        + tfcoil_variables.m_tf_wp_steel_conduit
        + tfcoil_variables.m_tf_coil_wp_turn_insulation
    )
    # ---------------------------------

    # Total TF coil mass [kg] (all coils)
    tfcoil_variables.m_tf_coils_total = (
        tfcoil_variables.m_tf_coil_case
        + tfcoil_variables.m_tf_coil_conductor
        + tfcoil_variables.m_tf_coil_wp_insulation
    ) * tfcoil_variables.n_tf_coils

    # If spherical tokamak, distribute between centrepost and outboard legs
    # (in this case, total TF coil length = inboard `cplen` + outboard `len_tf_coil`)
    if physics_variables.itart == 1:
        tfleng_sph = tfcoil_variables.cplen + tfcoil_variables.len_tf_coil
        tfcoil_variables.whtcp = tfcoil_variables.m_tf_coils_total * (
            tfcoil_variables.cplen / tfleng_sph
        )
        tfcoil_variables.whttflgs = tfcoil_variables.m_tf_coils_total * (
            tfcoil_variables.len_tf_coil / tfleng_sph
        )

lambda_term(tau, omega) staticmethod

The lambda function used inegral in inductance calcuation found in Y. Itoh et al. The full form of the functions are given in appendix A.

Parameters:

Name Type Description Default
tau float

tau_{s,k} = (R_{s,k} - R_{c,k}) / R_k

required
omega float

omega_k = R_{c,k}/R_k

required

Returns:

Type Description
float

integral

Source code in process/models/tfcoil/superconducting.py
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
@staticmethod
def lambda_term(tau: float, omega: float) -> float:
    """The lambda function used inegral in inductance calcuation found
    in Y. Itoh et al. The full form of the functions are given in appendix A.

    Parameters
    ----------
    tau :
        tau_{s,k} = (R_{s,k} - R_{c,k}) / R_k
    omega :
        omega_k = R_{c,k}/R_k

    Returns
    -------
    :
        integral
    """
    p = 1.0 - omega**2.0

    if p < 0:
        integral = (1.0 / np.sqrt(np.abs(p))) * np.arcsin(
            (1.0 + omega * tau) / (tau + omega)
        )
    else:
        integral = (1.0 / np.sqrt(np.abs(p))) * np.log(
            (2.0 * (1.0 + tau * omega - np.sqrt(p * (1 - tau**2.0)))) / (tau + omega)
        )

    return integral

vv_stress_on_quench(H_coil, ri_coil, ro_coil, rm_coil, ccl_length_coil, theta1_coil, H_vv, ri_vv, ro_vv, rm_vv, theta1_vv, n_tf_coils, n_tf_coil_turns, s_rp, s_cc, taud, i_op, d_vv)

Generic model to calculate the Tresca stress of the Vacuum Vessel (VV), experienced when the TF coil quenches.

The current center line (CCL) of a structure is an appoximation of where the poloidal current of a structure acts. This model considers how the current (self-)induced in the following structures affects the Tresca stress on the VV (corresponding to the structure index used in [1]):

  1. the TF coil conductors
  2. the TF coil steel structure
  3. the VV

Parameters:

Name Type Description Default
H_coil float

the maximum height of the TF coil CCL

required
ri_coil float

the radius of the inboard edge of the TF coil CCL

required
ro_coil float

the radius of the outboard edge of the TF coil CCL

required
rm_coil float

the radius where the maximum height of the TF coil CCL occurs

required
ccl_length_coil float

the length of the TF coil CCL

required
theta1_coil float

the polar angle of the point at which one circular arc is joined to another circular arc in the approximation to the coil CCL, using an arbitrary origin of coordinates (Rc2, Zc2).

required
H_vv float

the maximum height of the VV CCL

required
ri_vv float

the radius of the inboard edge of the VV CCL

required
ro_vv float

the radius of the outboard edge of the VV CCL

required
rm_vv float

the radius where the maximum height of the VV CCL occurs

required
theta1_vv float

the polar angle of the point at which one circular arc is joined to another circular arc in the approximation to the VV CCL, using an arbitrary origin of coordinates (Rc2, Zc2).

required
n_tf_coils float

the number of TF coils

required
n_tf_coil_turns float

the number of turns per TF coil

required
s_rp float

the cross-sectional area of the radial plates of the TF coil

required
s_cc float

the cross-sectional area of the TF coil case

required
taud float

the discharge time of the TF coil when quench occurs

required
i_op float

the 'normal' operating current of the TF coil

required
d_vv float

the thickness of the vacuum vessel shell

required

Returns:

Type Description
float

the maximum stress experienced by the vacuum vessel

Notes

The theta1 quantity for the TF coil and VV is not very meaningful. The impact of it of the inductance is rather small. Generally, the paper seems to suggest the TF coil is between 40 and 60, as this is the range they calculate the surrogates over. The thickness of the VV considers an ITER like design and only the outer and inner shells that which act of conductuve structural material.

References
  1. ITOH, Yasuyuki & Utoh, Hiroyasu & SAKAMOTO, Yoshiteru & Hiwatari, Ryoji. (2020). Empirical Formulas for Estimating Self and Mutual Inductances of Toroidal Field Coils and Structures. Plasma and Fusion Research. 15. 1405078-1405078. 10.1585/pfr.15.1405078.
Source code in process/models/tfcoil/superconducting.py
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
def vv_stress_on_quench(
    # TF shape
    H_coil: float,
    ri_coil: float,
    ro_coil: float,
    rm_coil: float,
    ccl_length_coil: float,
    theta1_coil: float,
    # VV shape
    H_vv: float,
    ri_vv: float,
    ro_vv: float,
    rm_vv: float,
    theta1_vv: float,
    # TF properties
    n_tf_coils: float,
    n_tf_coil_turns: float,
    s_rp: float,
    s_cc: float,
    taud: float,
    i_op: float,
    # VV properties
    d_vv: float,
) -> float:
    """Generic model to calculate the Tresca stress of the
    Vacuum Vessel (VV), experienced when the TF coil quenches.

    The current center line (CCL) of a structure is an appoximation
    of where the poloidal current of a structure acts. This model
    considers how the current (self-)induced in the following structures
    affects the Tresca stress on the VV (corresponding to the structure
    index used in [1]):

    0. the TF coil conductors
    1. the TF coil steel structure
    2. the VV

    Parameters
    ----------
    H_coil :
        the maximum height of the TF coil CCL
    ri_coil :
        the radius of the inboard edge of the TF coil CCL
    ro_coil :
        the radius of the outboard edge of the TF coil CCL
    rm_coil :
        the radius where the maximum height of the TF coil CCL occurs
    ccl_length_coil :
        the length of the TF coil CCL
    theta1_coil :
        the polar angle of the point at which one circular arc is
        joined to another circular arc in the approximation to the coil CCL,
        using an arbitrary origin of coordinates (Rc2, Zc2).
    H_vv :
        the maximum height of the VV CCL
    ri_vv :
        the radius of the inboard edge of the VV CCL
    ro_vv :
        the radius of the outboard edge of the VV CCL
    rm_vv :
        the radius where the maximum height of the VV CCL occurs
    theta1_vv :
        the polar angle of the point at which one circular arc is
        joined to another circular arc in the approximation to the VV CCL,
        using an arbitrary origin of coordinates (Rc2, Zc2).
    n_tf_coils :
        the number of TF coils
    n_tf_coil_turns :
        the number of turns per TF coil
    s_rp :
        the cross-sectional area of the radial plates of the TF coil
    s_cc :
        the cross-sectional area of the TF coil case
    taud :
        the discharge time of the TF coil when quench occurs
    i_op :
        the 'normal' operating current of the TF coil
    d_vv :
        the thickness of the vacuum vessel shell

    Returns
    -------
    :
        the maximum stress experienced by the vacuum vessel

    Notes
    -----
    The theta1 quantity for the TF coil and VV is not very meaningful. The
    impact of it of the inductance is rather small. Generally, the paper seems to
    suggest the TF coil is between 40 and 60, as this is the range they calculate
    the surrogates over. The thickness of the VV considers an ITER like design and
    only the outer and inner shells that which act of conductuve structural material.

    References
    ----------
    1. ITOH, Yasuyuki & Utoh, Hiroyasu & SAKAMOTO, Yoshiteru & Hiwatari, Ryoji. (2020).
    Empirical Formulas for Estimating Self and Mutual Inductances of Toroidal Field Coils and Structures.
    Plasma and Fusion Research. 15. 1405078-1405078. 10.1585/pfr.15.1405078.
    """
    # Convert angles into radians
    theta1_vv_rad = np.pi * (theta1_vv / 180.0)

    # Poloidal loop resistance (PLR) in ohms
    theta_vv = _theta_factor_integral(ro_vv, ri_vv, rm_vv, H_vv, theta1_vv_rad)
    plr_coil = ((0.5 * ccl_length_coil) / (n_tf_coils * (s_cc + s_rp))) * 1e-6
    plr_vv = ((0.84 / d_vv) * theta_vv) * 1e-6

    # relevant self-inductances in henry (H)
    coil_structure_self_inductance = (
        (constants.RMU0 / np.pi)
        * H_coil
        * _inductance_factor(H_coil, ri_coil, ro_coil, rm_coil, theta1_coil)
    )
    vv_self_inductance = (
        (constants.RMU0 / np.pi)
        * H_vv
        * _inductance_factor(H_vv, ri_vv, ro_vv, rm_vv, theta1_vv)
    )

    # s^-1
    lambda0 = 1 / taud
    lambda1 = (plr_coil) / coil_structure_self_inductance
    lambda2 = (plr_vv) / vv_self_inductance

    # approximate time at which the maximum force (and stress) will occur on the VV
    tmaxforce = np.log((lambda0 + lambda1) / (2 * lambda0)) / (lambda1 - lambda0)

    i0 = i_op * np.exp(-lambda0 * tmaxforce)
    i1 = (
        lambda0
        * n_tf_coils
        * n_tf_coil_turns
        * i_op
        * (
            (np.exp(-lambda1 * tmaxforce) - np.exp(-lambda0 * tmaxforce))
            / (lambda0 - lambda1)
        )
    )
    i2 = (lambda1 / lambda2) * i1

    a_vv = (ro_vv + ri_vv) / (ro_vv - ri_vv)
    b_vvi = (constants.RMU0 * (n_tf_coils * n_tf_coil_turns * i0 + i1 + (i2 / 2))) / (
        2 * np.pi * ri_vv
    )
    j_vvi = i2 / (2 * np.pi * d_vv * ri_vv)

    zeta = 1 + ((a_vv - 1) * np.log((a_vv + 1) / (a_vv - 1)) / (2 * a_vv))

    return zeta * b_vvi * j_vvi * ri_vv