Python API reference#

Assemblies#

paramak.tokamak(radial_build, vertical_build, triangularity=0.55, rotation_angle=180.0, extra_cut_shapes=None, extra_intersect_shapes=None, colors=None, poloidal_build=None, toroidal_build=None)[source]#

Creates a tokamak fusion reactor from a radial and vertical build.

Return type:

Assembly

Parameters:
  • radial_build – sequence of tuples containing the radial build of the reactor. Each tuple should contain a LayerType, a float and the string is optional.

  • vertical_build – sequence of tuples containing the vertical build of the reactor. Each tuple should contain a LayerType, a float and the string is optional.

  • triangularity – The triangularity of the plasma. Defaults to 0.55.

  • rotation_angle – The rotation angle of the plasma. Defaults to 180.0.

  • extra_cut_shapes – A list of extra shapes to cut the reactor with. Defaults to [].

  • extra_intersect_shapes – A list of extra shapes to intersect the reactor with. Defaults to [].

  • colors (dict, optional) – the colors to assign to the assembly parts. Defaults to {}. Each dictionary entry should be a key that matches the assembly part name (e.g. ‘plasma’, or ‘layer_1’) and a tuple of 3 or 4 floats between 0 and 1 representing the RGB or RGBA values.

  • poloidal_build – optional poloidal segmentation of the layers. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, so each entry covers the matching inboard and outboard layer pair. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments in the same format as radial_build entries: (paramak.LayerType.SOLID, arc_length, name) for a solid segment (the name is optional) or (paramak.LayerType.GAP, arc_length) for a gap that produces no solid. Arc lengths are measured along the plasma facing surface (the inner surface of the first solid layer after the plasma) for every layer, starting at the outboard midplane and proceeding counter clockwise (upwards on the outboard side). Each entry must sum to the arc length returned by paramak.poloidal_arc_length (within 0.1 percent). Cuts between segments follow the normal to the plasma surface, so layers given the same segments line up. Solid segments are named “<layer name>_<segment name>”, unnamed solid segments are called “segment”, and repeated names within a layer get a “_1”, “_2” suffix. Defaults to None.

  • toroidal_build – optional toroidal segmentation of the layers, for example into sectors separated by assembly gaps. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, like poloidal_build. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments: (paramak.LayerType.SOLID, arc_length, name) for a sector (the name is optional) or (paramak.LayerType.GAP, width) for a gap. Arc lengths are measured around the plasma facing surface at the outboard midplane, starting at the XZ plane and going in the direction the reactor is revolved, and each entry must sum to the arc length returned by paramak.toroidal_arc_length (within 0.1 percent). Gaps are slots with parallel sides, so a gap has the same width at every radius. Sectors are named “<layer name>_<sector name>”, or “<layer name>_<poloidal segment name>_<sector name>” when the layer also has a poloidal_build entry. Defaults to None.

Returns:

A CadQuery Assembly object representing the tokamak fusion reactor.

Return type:

CadQuery.Assembly

paramak.tokamak_from_plasma(radial_build, elongation=2.0, triangularity=0.55, rotation_angle=180.0, extra_cut_shapes=None, extra_intersect_shapes=None, colors=None, poloidal_build=None, toroidal_build=None)[source]#

Creates a tokamak fusion reactor from a radial build and plasma parameters.

Return type:

Assembly

Parameters:
  • radial_build – sequence of tuples containing the radial build of the reactor. Each tuple should contain a LayerType, a float and a string.

  • elongation – The elongation of the plasma. Defaults to 2.0.

  • triangularity – The triangularity of the plasma. Defaults to 0.55.

  • rotation_angle – The rotation angle of the plasma. Defaults to 180.0.

  • extra_cut_shapes – A list of extra shapes to cut the reactor with. Defaults to [].

  • extra_intersect_shapes – A list of extra shapes to intersect the reactor with. Defaults to [].

  • colors (dict, optional) – the colors to assign to the assembly parts. Defaults to {}. Each dictionary entry should be a key that matches the assembly part name (e.g. ‘plasma’, or ‘layer_1’) and a tuple of 3 or 4 floats between 0 and 1 representing the RGB or RGBA values.

  • poloidal_build – optional poloidal segmentation of the layers. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, so each entry covers the matching inboard and outboard layer pair. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments in the same format as radial_build entries: (paramak.LayerType.SOLID, arc_length, name) for a solid segment (the name is optional) or (paramak.LayerType.GAP, arc_length) for a gap that produces no solid. Arc lengths are measured along the plasma facing surface (the inner surface of the first solid layer after the plasma) for every layer, starting at the outboard midplane and proceeding counter clockwise (upwards on the outboard side). Each entry must sum to the arc length returned by paramak.poloidal_arc_length (within 0.1 percent). Cuts between segments follow the normal to the plasma surface, so layers given the same segments line up. Solid segments are named “<layer name>_<segment name>”, unnamed solid segments are called “segment”, and repeated names within a layer get a “_1”, “_2” suffix. Defaults to None.

  • toroidal_build – optional toroidal segmentation of the layers, for example into sectors separated by assembly gaps. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, like poloidal_build. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments: (paramak.LayerType.SOLID, arc_length, name) for a sector (the name is optional) or (paramak.LayerType.GAP, width) for a gap. Arc lengths are measured around the plasma facing surface at the outboard midplane, starting at the XZ plane and going in the direction the reactor is revolved, and each entry must sum to the arc length returned by paramak.toroidal_arc_length (within 0.1 percent). Gaps are slots with parallel sides, so a gap has the same width at every radius. Sectors are named “<layer name>_<sector name>”, or “<layer name>_<poloidal segment name>_<sector name>” when the layer also has a poloidal_build entry. Defaults to None.

Returns:

A CadQuery Assembly object representing the tokamak fusion reactor.

Return type:

CadQuery.Assembly

paramak.spherical_tokamak(radial_build, vertical_build, triangularity=0.55, rotation_angle=180.0, extra_cut_shapes=None, extra_intersect_shapes=None, colors=None, poloidal_build=None, toroidal_build=None)[source]#

Creates a spherical tokamak fusion reactor from a radial build and vertical build.

Return type:

Assembly

Parameters:
  • radial_build – sequence of tuples containing the radial build of the reactor. Each tuple should contain a LayerType, a float and the string is optional.

  • vertical_build – sequence of tuples containing the vertical build of the reactor. Each tuple should contain a LayerType, a float and the string is optional.

  • triangularity – The triangularity of the plasma. Defaults to 0.55.

  • rotation_angle – The rotation angle of the reactor in degrees. Defaults to 180.0.

  • extra_cut_shapes – A list of extra shapes to cut the reactor with. Defaults to [].

  • extra_intersect_shapes – A list of extra shapes to intersect the reactor with. Defaults to [].

  • colors – the colors to assign to the assembly parts. Defaults to {}. Each dictionary entry should be a key that matches the assembly part name (e.g. ‘plasma’, or ‘layer_1’) and a tuple of 3 or 4 floats between 0 and 1 representing the RGB or RGBA values.

  • poloidal_build – optional poloidal segmentation of the layers after the plasma. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments in the same format as radial_build entries: (paramak.LayerType.SOLID, arc_length, name) for a solid segment (the name is optional) or (paramak.LayerType.GAP, arc_length) for a gap that produces no solid. Arc lengths are measured along the plasma facing surface (the inner surface of the first solid layer after the plasma) for every layer, starting where the layer meets the centre column at the bottom and going along the bottom, up the outboard side and along the top back to the centre column. Each entry must sum to the arc length returned by paramak.spherical_poloidal_arc_length (within 0.1 percent). Cuts between segments are vertical along the top and bottom and follow the normal to the plasma surface on the outboard side, so layers given the same segments line up. Solid segments are named “<layer name>_<segment name>”, unnamed solid segments are called “segment”, and repeated names within a layer get a “_1”, “_2” suffix. Defaults to None.

  • toroidal_build – optional toroidal segmentation of the layers, for example into sectors separated by assembly gaps. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, like poloidal_build. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments: (paramak.LayerType.SOLID, arc_length, name) for a sector (the name is optional) or (paramak.LayerType.GAP, width) for a gap. Arc lengths are measured around the plasma facing surface at the outboard midplane, starting at the XZ plane and going in the direction the reactor is revolved, and each entry must sum to the arc length returned by paramak.toroidal_arc_length (within 0.1 percent). Gaps are slots with parallel sides, so a gap has the same width at every radius. Sectors are named “<layer name>_<sector name>”, or “<layer name>_<poloidal segment name>_<sector name>” when the layer also has a poloidal_build entry. Defaults to None.

Returns:

A CadQuery Assembly object representing the spherical tokamak fusion reactor.

Return type:

CadQuery.Assembly

paramak.spherical_tokamak_from_plasma(radial_build, elongation=2.0, triangularity=0.55, rotation_angle=180.0, extra_cut_shapes=None, extra_intersect_shapes=None, colors=None, poloidal_build=None, toroidal_build=None)[source]#

Creates a spherical tokamak fusion reactor from a radial build and plasma parameters.

Return type:

Assembly

Parameters:
  • radial_build – sequence of tuples containing the radial build of the reactor. Each tuple should contain a LayerType, a float and the string is optional.

  • elongation – The elongation of the plasma. Defaults to 2.0.

  • triangularity – The triangularity of the plasma. Defaults to 0.55.

  • rotation_angle – The rotation angle of the reactor in degrees. Defaults to 180.0.

  • extra_cut_shapes – A list of extra shapes to cut the reactor with. Defaults to [].

  • colors – the colors to assign to the assembly parts. Defaults to {}. Each dictionary entry should be a key that matches the assembly part name (e.g. ‘plasma’, or ‘layer_1’) and a tuple of 3 or 4 floats between 0 and 1 representing the RGB or RGBA values.

  • poloidal_build – optional poloidal segmentation of the layers after the plasma. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments in the same format as radial_build entries: (paramak.LayerType.SOLID, arc_length, name) for a solid segment (the name is optional) or (paramak.LayerType.GAP, arc_length) for a gap that produces no solid. Arc lengths are measured along the plasma facing surface (the inner surface of the first solid layer after the plasma) for every layer, starting where the layer meets the centre column at the bottom and going along the bottom, up the outboard side and along the top back to the centre column. Each entry must sum to the arc length returned by paramak.spherical_poloidal_arc_length (within 0.1 percent). Cuts between segments are vertical along the top and bottom and follow the normal to the plasma surface on the outboard side, so layers given the same segments line up. Solid segments are named “<layer name>_<segment name>”, unnamed solid segments are called “segment”, and repeated names within a layer get a “_1”, “_2” suffix. Defaults to None.

  • toroidal_build – optional toroidal segmentation of the layers, for example into sectors separated by assembly gaps. A list with one entry per radial_build entry after the plasma, ordered from the plasma outwards, like poloidal_build. Entries are None for layers that are not segmented (and must be None for LayerType.GAP entries), otherwise a list of segments: (paramak.LayerType.SOLID, arc_length, name) for a sector (the name is optional) or (paramak.LayerType.GAP, width) for a gap. Arc lengths are measured around the plasma facing surface at the outboard midplane, starting at the XZ plane and going in the direction the reactor is revolved, and each entry must sum to the arc length returned by paramak.toroidal_arc_length (within 0.1 percent). Gaps are slots with parallel sides, so a gap has the same width at every radius. Sectors are named “<layer name>_<sector name>”, or “<layer name>_<poloidal segment name>_<sector name>” when the layer also has a poloidal_build entry. Defaults to None.

Returns:

A CadQuery Assembly object representing the spherical tokamak fusion reactor.

Return type:

CadQuery.Assembly

Utilities#

paramak.poloidal_arc_length(radial_build, elongation=None, triangularity=0.55, vertical_build=None)[source]#

Returns the poloidal arc length that the segments in a poloidal_build must sum to.

The arc length is measured around the full poloidal loop of the plasma facing surface, which is the inner surface of the first solid layer after the plasma. All poloidal_build entries are measured on this surface, so layers given the same segments line up.

Return type:

float

Parameters:
  • radial_build – the radial build of the reactor, as passed to tokamak_from_plasma or tokamak.

  • elongation – the elongation of the plasma, as passed to tokamak_from_plasma. Defaults to 2.0. Must not be set when a vertical_build is provided, as the elongation is then calculated from the builds.

  • triangularity – the triangularity of the plasma. Defaults to 0.55.

  • vertical_build – the vertical build of the reactor, as passed to tokamak. Leave as None for tokamak_from_plasma.

Returns:

the poloidal arc length of the plasma facing surface.

Return type:

float

paramak.spherical_poloidal_arc_length(radial_build, elongation=None, triangularity=0.55, vertical_build=None)[source]#

Returns the arc length that the segments in a spherical tokamak poloidal_build must sum to.

The arc length is measured along the plasma facing surface, which is the inner surface of the first solid layer after the plasma. This surface runs from the centre column along the bottom of the layer, around the outboard side of the plasma and back along the top of the layer to the centre column. All poloidal_build entries are measured on this surface, so layers given the same segments line up.

Return type:

float

Parameters:
  • radial_build – the radial build of the reactor, as passed to spherical_tokamak_from_plasma or spherical_tokamak.

  • elongation – the elongation of the plasma, as passed to spherical_tokamak_from_plasma. Defaults to 2.0. Must not be set when a vertical_build is provided, as the elongation is then calculated from the builds.

  • triangularity – the triangularity of the plasma. Defaults to 0.55.

  • vertical_build – the vertical build of the reactor, as passed to spherical_tokamak. Leave as None for spherical_tokamak_from_plasma.

Returns:

the arc length of the plasma facing surface.

Return type:

float

paramak.toroidal_arc_length(radial_build, rotation_angle=180.0)[source]#

Returns the toroidal arc length that the segments in a toroidal_build must sum to.

The arc length is measured around the plasma facing surface (the inner surface of the first solid layer after the plasma) at the outboard midplane, over the rotation_angle of the reactor. This works for all the reactor types, as the outboard midplane radius only depends on the radial_build.

Return type:

float

Parameters:
  • radial_build – the radial build of the reactor, as passed to the reactor function.

  • rotation_angle – the rotation angle of the reactor in degrees, as passed to the reactor function. Defaults to 180.0.

Returns:

the toroidal arc length.

Return type:

float

Workplanes#

paramak.blanket_from_plasma(thickness, start_angle, stop_angle, minor_radius=150.0, major_radius=450.0, triangularity=0.55, elongation=2.0, vertical_displacement=0.0, offset_from_plasma=0.0, num_points=200, name='blanket_from_plasma', color=(0.333, 0.0, 0.0), rotation_angle=90.0, plane='XZ', origin=(0, 0, 0), obj=None, allow_overlapping_shape=False, connect_to_center=False)[source]#

A blanket volume created from plasma parameters. It might be necessary to increase the num_points when making long but thin geometry with this component.

Parameters:
  • thickness (float or [float] or callable or [(float), (float)]) – the thickness of the blanket (cm). If the thickness is a float then this produces a blanket of constant thickness. If the thickness is a tuple of floats, blanket thickness will vary linearly between the two values. If thickness is callable, then the blanket thickness will be a function of poloidal angle (in degrees). If thickness is a list of two lists (thicknesses and angles) then these will be used together with linear interpolation.

  • start_angle – the angle in degrees to start the blanket, measured anti clockwise from 3 o’clock.

  • stop_angle – the angle in degrees to stop the blanket, measured anti clockwise from 3 o’clock.

  • plasma – If not None, the parameters of the plasma Object will be used.

  • minor_radius – the minor radius of the plasma (cm).

  • major_radius – the major radius of the plasma (cm).

  • triangularity – the triangularity of the plasma.

  • elongation – the elongation of the plasma.

  • vertical_displacement – the vertical_displacement of the plasma (cm).

  • offset_from_plasma – the distance between the plasma and the blanket (cm). If float, constant offset. If list of floats, offset will vary linearly between the values. If callable, offset will be a function of poloidal angle (in degrees). If a list of two lists (angles and offsets) then these will be used together with linear interpolation.

  • num_points – number of points that will describe the shape.

  • allow_overlapping_shape – allows parameters to create a shape that overlaps itself.

paramak.center_column_shield_cylinder(height, inner_radius, thickness, reference_point=('center', 0), name='center_column_shield_cylinder', color=(0.0, 0.333, 0.0), rotation_angle=90, plane='XZ', origin=(0, 0, 0), obj=None)[source]#

A cylindrical center column shield volume with constant thickness.

Parameters:
  • height – height of the center column shield.

  • inner_radius – the inner radius of the center column shield.

  • thickness – the outer radius of the center column shield.

  • reference_point – the vertical coordinates to build the vessel from and description of the reference point. Can be either the ‘center’ with a numerical value or ‘lower’ with a numerical value.

paramak.constant_thickness_dome(thickness=10, chord_center_height=0, chord_width=100, chord_height=20, upper_or_lower='upper', name='constant_thickness_dome', plane='XZ', color=(0.0, 0.333, 0.0), origin=(0, 0, 0), rotation_angle=90, obj=None, **kwargs)[source]#

A cylindrical vessel volume with constant thickness with a simple dished head. This style of tank head has no knuckle radius or straight flange. The dished shape is made from a chord of a circle.

Parameters:
  • thickness – the radial thickness of the dome.

  • chord_center_height – the vertical position of the chord center

  • chord_width – the width of the chord base

  • chord_height – the height of the chord which is also distance between the chord_center_height and the inner surface of the dome

  • upper_or_lower – Curves the dish with a positive or negative direction to allow the upper section or lower section of vacuum vessel domes to be made.

  • name – the name of the shape, used in the graph legend and as a filename prefix when exporting.

paramak.cutting_wedge(height, radius, rotation_angle=180.0, plane='XZ', origin=(0, 0, 0), obj=None, color=(0.0, 0.333, 0.0), name='cutting_wedge')[source]#

Creates a wedge from height, radius and rotation angle arguments than can be useful for cutting sector models.

Parameters:
  • height – the vertical (z axis) height of the coil (cm).

  • radius – the horizontal (x axis) width of the coil (cm).

  • rotation_angle – Defaults to 180.0.

paramak.dished_vacuum_vessel(radius=300, reference_point=('center', 0), dish_height=(20, 50), cylinder_height=400, thickness=15, rotation_angle=90, name='dished_vessel', plane='XZ')[source]#

A cylindrical vessel volume with constant thickness with a simple dished head. This style of tank head has no knuckle radius or straight flange.

Parameters:
  • radius – the radius from which the centres of the vessel meets the outer circumference.

  • reference_point – the x,z coordinates to build the vessel from. Can be either the ‘center’ with a value or ‘lower’ with a value. For example

  • dish_height – the height of the lower and upper dish sections.

  • cylinder_height – the height of the cylindrical section of the vacuum vessel.

  • thickness – the radial thickness of the vessel in cm.

paramak.plasma_simplified(elongation=2.0, major_radius=450.0, minor_radius=150.0, triangularity=0.55, vertical_displacement=0.0, num_points=200, name='tokamak_plasma', color=(0.333, 0.0, 0.0), rotation_angle=90, plane='XZ', origin=(0, 0, 0), obj=None)[source]#

Creates a double null tokamak plasma shape that is controlled by 4 shaping parameters.

Parameters:
  • elongation – the elongation of the plasma.

  • major_radius – the major radius of the plasma (cm).

  • minor_radius – the minor radius of the plasma (cm).

  • triangularity – the triangularity of the plasma.

  • vertical_displacement – the vertical_displacement of the plasma (cm)..

  • num_points – number of points to describe the shape.

paramak.poloidal_field_coil_case(coil_height, coil_width, casing_thickness, center_point, name='poloidal_field_coil_case', color=(1.0, 1.0, 0.498), rotation_angle=90, plane='XZ', origin=(0, 0, 0), obj=None)[source]#

Constant thickness casing for a rectangular poloidal coil.

Parameters:
  • coil_height – the vertical (z axis) height of the coil (cm).

  • coil_width – the horizontal (x axis) width of the coil (cm).

  • center_point – the center of the coil (x,z) values (cm).

  • casing_thickness – the thickness of the coil casing (cm).

paramak.poloidal_field_coil(height, width, center_point, name='poloidal_field_coil', color=(0.0, 0.333, 0.0), rotation_angle=90, plane='XZ', origin=(0, 0, 0), obj=None)[source]#

A rectangular poloidal field coil.

Parameters:
  • height – the vertical (z axis) height of the coil.

  • width – the horizontal (x axis) width of the coil.

  • center_point – the center of the coil (x,z) values.

paramak.revolved_shape(points, rotation_angle=360.0, name='revolved_shape', color=(0.5, 0.5, 0.5), plane='XZ', origin=(0, 0, 0), obj=None)[source]#

Creates a solid by revolving an arbitrary closed 2D profile around the axis.

The profile is described by a list of points where each point is a (R, Z, connection) tuple. connection is one of "straight", "spline" or "circle" and describes how that point joins to the next one. This is the same profile description used internally by paramak’s blanket and dome components, so splines and arcs produce smooth curved profiles rather than blocky polylines.

The profile is closed automatically, so the first point should not be repeated at the end of the list. This is convenient for building custom shapes to pass to the extra_intersect_shapes or extra_cut_shapes arguments of the reactor assemblies, for example a curved divertor.

Return type:

Workplane

Parameters:
  • points – the profile points as (R, Z, connection) tuples, ordered around the outline. Do not repeat the first point; the profile is closed automatically.

  • rotation_angle – the angle in degrees to revolve the profile around the axis. Defaults to 360.

  • name – the name assigned to the resulting solid.

  • color – the RGB(A) color assigned to the resulting solid.

  • plane – the plane to build the profile on, e.g. “XZ”.

  • origin – the origin of the workplane.

  • obj – an optional existing CadQuery object to build upon.

Returns:

A CadQuery Workplane containing the revolved solid.

paramak.toroidal_field_coil_rectangle(horizontal_start_point=(20, 200), vertical_mid_point=(350, 0), thickness=30, distance=20, rotation_angle=360.0, name='toroidal_field_coil', with_inner_leg=True, azimuthal_placement_angles=None, vertical_displacement=0.0, color=(0.0, 0.0, 1.0), plane='XZ', origin=(0.0, 0.0, 0.0), obj=None)[source]#

Creates a rectangular shaped toroidal field coil.

Parameters:
  • horizontal_start_point – the (x,z) coordinates of the inner upper point (cm).

  • vertical_mid_point – the (x,z) coordinates of the mid point of the vertical section (cm).

  • thickness – the thickness of the toroidal field coil.

  • distance – the extrusion distance.

  • rotation_angle (float) – angle of rotation in degrees, this cuts the resulting shape with a wedge. Useful for sector models.

  • with_inner_leg – include the inner tf leg. Defaults to True.

  • azimuth_start_angle – The azimuth angle to for the first TF coil which offsets the placement of coils around the azimuthal angle

paramak.u_shaped_dome(radius=310, reference_point=('lower', 0), dish_height=50, cylinder_height=400, thickness=16, rotation_angle=180, name='u_shaped_dome', plane='XZ', upper_or_lower='upper')[source]#

A cylindrical u shaped dome with constant thickness.

Parameters:
  • radius – the radius from which the centres of the vessel meets the outer circumference.

  • reference_point – the x,z coordinates to build the vessel from. Can be either the ‘center’ with a value or ‘lower’ with a value. For example

  • dish_height – the height of the dish section.

  • cylinder_height – the height of the cylindrical section of the vacuum vessel.

  • thickness – the radial thickness of the vessel in cm.