Skip to content

Commit ade633a

Browse files
committed
added more complete example
1 parent 4a8c2b1 commit ade633a

File tree

3 files changed

+267
-1
lines changed

3 files changed

+267
-1
lines changed

docs/usage.rst

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,173 @@ Spherical tokamak with negative triangularity
711711
triangularity=-0.55,
712712
)
713713
result.save(f"spherical_tokamak_minimal.step")
714+
715+
716+
Tokamak with several customizations
717+
-----------------------------------
718+
719+
- Combining many of the examples together to produce a Tokamak
720+
with extra blanket layers, a lower divertor, PF and TF coils.
721+
722+
.. cadquery::
723+
:gridsize: 0
724+
:select: result
725+
:color: #00cd00
726+
:width: 100%
727+
:height: 600px
728+
729+
import paramak
730+
from cadquery import vis, Workplane
731+
732+
# makes a rectangle that overlaps the lower blanket under the plasma
733+
# the intersection of this and the layers will form the lower divertor
734+
points = [(300, -700), (300, 0), (400, 0), (400, -700)]
735+
divertor_lower = Workplane('XZ', origin=(0,0,0)).polyline(points).close().revolve(180)
736+
737+
# creates a toroidal
738+
tf = paramak.toroidal_field_coil_rectangle(
739+
horizontal_start_point = (10, 520),
740+
vertical_mid_point = (860, 0),
741+
thickness = 50,
742+
distance = 40,
743+
with_inner_leg = True,
744+
azimuthal_placement_angles = [0, 30, 60, 90, 120, 150, 180],
745+
)
746+
747+
add_extra_cut_shapes = [tf]
748+
749+
# creates pf coil
750+
for case_thickness, height, width, center_point in zip(
751+
[10, 15, 15, 10], [20, 50, 50, 20], [20, 50, 50, 20],
752+
[(730, 370), (810, 235), (810, -235), (730, -370)]
753+
):
754+
add_extra_cut_shapes.append(
755+
paramak.poloidal_field_coil(
756+
height=height, width=width, center_point=center_point, rotation_angle=180
757+
)
758+
)
759+
add_extra_cut_shapes.append(
760+
paramak.poloidal_field_coil_case(
761+
coil_height=height,
762+
coil_width=width,
763+
casing_thickness=case_thickness,
764+
rotation_angle=180,
765+
center_point=center_point,
766+
)
767+
)
768+
769+
result = paramak.tokamak(
770+
radial_build=[
771+
(paramak.LayerType.GAP, 10),
772+
(paramak.LayerType.SOLID, 30),
773+
(paramak.LayerType.SOLID, 50),
774+
(paramak.LayerType.SOLID, 10),
775+
(paramak.LayerType.SOLID, 60),
776+
(paramak.LayerType.SOLID, 60),
777+
(paramak.LayerType.SOLID, 20),
778+
(paramak.LayerType.GAP, 60),
779+
(paramak.LayerType.PLASMA, 300),
780+
(paramak.LayerType.GAP, 60),
781+
(paramak.LayerType.SOLID, 20),
782+
(paramak.LayerType.SOLID, 60),
783+
(paramak.LayerType.SOLID, 60),
784+
(paramak.LayerType.SOLID, 10),
785+
],
786+
vertical_build=[
787+
(paramak.LayerType.SOLID, 10),
788+
(paramak.LayerType.SOLID, 50),
789+
(paramak.LayerType.SOLID, 50),
790+
(paramak.LayerType.SOLID, 20),
791+
(paramak.LayerType.GAP, 60),
792+
(paramak.LayerType.PLASMA, 650),
793+
(paramak.LayerType.GAP, 60),
794+
(paramak.LayerType.SOLID, 20),
795+
(paramak.LayerType.SOLID, 50),
796+
(paramak.LayerType.SOLID, 50),
797+
(paramak.LayerType.SOLID, 10),
798+
],
799+
triangularity=0.55,
800+
rotation_angle=180,
801+
add_extra_cut_shapes=add_extra_cut_shapes,
802+
extra_intersect_shapes=[divertor_lower]
803+
)
804+
result.toCompound()
805+
806+
.. code-block:: python
807+
808+
import paramak
809+
from cadquery import vis, Workplane
810+
811+
# makes a rectangle that overlaps the lower blanket under the plasma
812+
# the intersection of this and the layers will form the lower divertor
813+
points = [(300, -700), (300, 0), (400, 0), (400, -700)]
814+
divertor_lower = Workplane('XZ', origin=(0,0,0)).polyline(points).close().revolve(180)
815+
816+
# creates a toroidal
817+
tf = paramak.toroidal_field_coil_rectangle(
818+
horizontal_start_point = (10, 520),
819+
vertical_mid_point = (860, 0),
820+
thickness = 50,
821+
distance = 40,
822+
with_inner_leg = True,
823+
azimuthal_placement_angles = [0, 30, 60, 90, 120, 150, 180],
824+
)
825+
826+
add_extra_cut_shapes = [tf]
827+
828+
# creates pf coil
829+
for case_thickness, height, width, center_point in zip(
830+
[10, 15, 15, 10], [20, 50, 50, 20], [20, 50, 50, 20],
831+
[(730, 370), (810, 235), (810, -235), (730, -370)]
832+
):
833+
add_extra_cut_shapes.append(
834+
paramak.poloidal_field_coil(
835+
height=height, width=width, center_point=center_point, rotation_angle=180
836+
)
837+
)
838+
add_extra_cut_shapes.append(
839+
paramak.poloidal_field_coil_case(
840+
coil_height=height,
841+
coil_width=width,
842+
casing_thickness=case_thickness,
843+
rotation_angle=180,
844+
center_point=center_point,
845+
)
846+
)
847+
848+
my_reactor = paramak.tokamak(
849+
radial_build=[
850+
(paramak.LayerType.GAP, 10),
851+
(paramak.LayerType.SOLID, 30),
852+
(paramak.LayerType.SOLID, 50),
853+
(paramak.LayerType.SOLID, 10),
854+
(paramak.LayerType.SOLID, 60),
855+
(paramak.LayerType.SOLID, 60),
856+
(paramak.LayerType.SOLID, 20),
857+
(paramak.LayerType.GAP, 60),
858+
(paramak.LayerType.PLASMA, 300),
859+
(paramak.LayerType.GAP, 60),
860+
(paramak.LayerType.SOLID, 20),
861+
(paramak.LayerType.SOLID, 60),
862+
(paramak.LayerType.SOLID, 60),
863+
(paramak.LayerType.SOLID, 10),
864+
],
865+
vertical_build=[
866+
(paramak.LayerType.SOLID, 10),
867+
(paramak.LayerType.SOLID, 50),
868+
(paramak.LayerType.SOLID, 50),
869+
(paramak.LayerType.SOLID, 20),
870+
(paramak.LayerType.GAP, 60),
871+
(paramak.LayerType.PLASMA, 650),
872+
(paramak.LayerType.GAP, 60),
873+
(paramak.LayerType.SOLID, 20),
874+
(paramak.LayerType.SOLID, 50),
875+
(paramak.LayerType.SOLID, 50),
876+
(paramak.LayerType.SOLID, 10),
877+
],
878+
triangularity=0.55,
879+
rotation_angle=180,
880+
add_extra_cut_shapes=add_extra_cut_shapes,
881+
extra_intersect_shapes=[divertor_lower]
882+
)
883+
my_reactor.save(f"tokamak_with_divertor.step")
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
from example_util_functions import transport_particles_on_h5m_geometry
3+
4+
import paramak
5+
from cadquery import vis, Workplane
6+
7+
# makes a rectangle that overlaps the lower blanket under the plasma
8+
# the intersection of this and the layers will form the lower divertor
9+
points = [(300, -700), (300, 0), (400, 0), (400, -700)]
10+
divertor_lower = Workplane('XZ', origin=(0,0,0)).polyline(points).close().revolve(180)
11+
12+
# creates a toroidal
13+
tf = paramak.toroidal_field_coil_rectangle(
14+
horizontal_start_point = (10, 520),
15+
vertical_mid_point = (860, 0),
16+
thickness = 50,
17+
distance = 40,
18+
with_inner_leg = True,
19+
azimuthal_placement_angles = [0, 30, 60, 90, 120, 150, 180],
20+
)
21+
22+
add_extra_cut_shapes = [tf]
23+
24+
# creates pf coil
25+
for case_thickness, height, width, center_point in zip(
26+
[10, 15, 15, 10], [20, 50, 50, 20], [20, 50, 50, 20],
27+
[(730, 370), (810, 235), (810, -235), (730, -370)]
28+
):
29+
add_extra_cut_shapes.append(
30+
paramak.poloidal_field_coil(
31+
height=height, width=width, center_point=center_point, rotation_angle=180
32+
)
33+
)
34+
add_extra_cut_shapes.append(
35+
paramak.poloidal_field_coil_case(
36+
coil_height=height,
37+
coil_width=width,
38+
casing_thickness=case_thickness,
39+
rotation_angle=180,
40+
center_point=center_point,
41+
)
42+
)
43+
44+
my_reactor = paramak.tokamak(
45+
radial_build=[
46+
(paramak.LayerType.GAP, 10),
47+
(paramak.LayerType.SOLID, 30),
48+
(paramak.LayerType.SOLID, 50),
49+
(paramak.LayerType.SOLID, 10),
50+
(paramak.LayerType.SOLID, 60),
51+
(paramak.LayerType.SOLID, 60),
52+
(paramak.LayerType.SOLID, 20),
53+
(paramak.LayerType.GAP, 60),
54+
(paramak.LayerType.PLASMA, 300),
55+
(paramak.LayerType.GAP, 60),
56+
(paramak.LayerType.SOLID, 20),
57+
(paramak.LayerType.SOLID, 60),
58+
(paramak.LayerType.SOLID, 60),
59+
(paramak.LayerType.SOLID, 10),
60+
],
61+
vertical_build=[
62+
(paramak.LayerType.SOLID, 10),
63+
(paramak.LayerType.SOLID, 50),
64+
(paramak.LayerType.SOLID, 50),
65+
(paramak.LayerType.SOLID, 20),
66+
(paramak.LayerType.GAP, 60),
67+
(paramak.LayerType.PLASMA, 650),
68+
(paramak.LayerType.GAP, 60),
69+
(paramak.LayerType.SOLID, 20),
70+
(paramak.LayerType.SOLID, 50),
71+
(paramak.LayerType.SOLID, 50),
72+
(paramak.LayerType.SOLID, 10),
73+
],
74+
triangularity=0.55,
75+
rotation_angle=180,
76+
add_extra_cut_shapes=add_extra_cut_shapes,
77+
extra_intersect_shapes=[divertor_lower]
78+
)
79+
my_reactor.save(f"tokamak_with_divertor.step")
80+
print(f"Saved as tokamak_with_divertor.step")
81+
vis.show(my_reactor)
82+
83+
# from cad_to_dagmc import CadToDagmc
84+
# my_model = CadToDagmc()
85+
# material_tags = ["mat1"] * 6 # as inner and outer layers are one solid there are only 6 solids in model
86+
# my_model.add_cadquery_object(cadquery_object=my_reactor, material_tags=material_tags)
87+
# my_model.export_dagmc_h5m_file(min_mesh_size=3.0, max_mesh_size=20.0)
88+
89+
# h5m_filename = "dagmc.h5m"
90+
# flux = transport_particles_on_h5m_geometry(
91+
# h5m_filename=h5m_filename,
92+
# material_tags=material_tags,
93+
# nuclides=["H1"] * len(material_tags),
94+
# cross_sections_xml="tests/cross_sections.xml",
95+
# )
96+
# assert flux > 0.0

src/paramak/assemblies/tokamak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def tokamak(
283283
my_assembly.add(entry, name=f"outboard_layer_{i+1})")
284284
else:
285285
shapes_and_components = []
286-
for i, entry in enumerate(inner_radial_build + blanket_layers + divertor_layers):
286+
for i, entry in enumerate(inner_radial_build + blanket_layers):
287287
for cutter in add_extra_cut_shapes + extra_intersect_shapes:
288288
entry = entry.cut(cutter)
289289
# TODO use something like this to return a list of material tags for the solids in order, as some solids get split into multiple

0 commit comments

Comments
 (0)