Reactor() class¶
The Reactor() class allows Shapes() to be grouped together and jointly operated on.
Reactor()¶
- class Reactor(shapes_and_components=[], graveyard_size=20000.0, graveyard_offset=None, largest_shapes=None)¶
Bases:
object
The Reactor object allows shapes and components to be added and then collective operations to be performed on them. Combining all the shapes is required for creating images of the whole reactor and creating a Graveyard (bounding box) that is useful for neutronics simulations.
- Parameters
shapes_and_components – list of paramak.Shape objects
graveyard_size – The dimension of cube shaped the graveyard region used by DAGMC. This attribute is used preferentially over graveyard_offset.
graveyard_offset – The distance between the graveyard and the largest shape. If graveyard_size is set the this is ignored.
largest_shapes – Identifying the shape(s) with the largest size in each dimension (x,y,z) can speed up the production of the graveyard. Defaults to None which finds the largest shapes by looping through all the shapes and creating bounding boxes. This can be slow and that is why the user is able to provide a subsection of shapes to use when calculating the graveyard dimensions.
- export_2d_image(filename='2d_slice.png', xmin=0.0, xmax=900.0, ymin=- 600.0, ymax=600.0)¶
Creates a 2D slice image (png) of the reactor.
- Parameters
filename (str) – output filename of the image created
- Returns
png filename created
- Return type
str
- Return type
str
- export_brep(filename, merge=True)¶
Exports a brep file for the Reactor.solid.
- Parameters
filename – the filename of exported the brep file.
merged – if the surfaces should be merged (True) or not (False).
- Returns
filename of the brep created
- export_dagmc_h5m(filename='dagmc.h5m', min_mesh_size=5, max_mesh_size=20, exclude=None, verbose=False, volume_atol=1e-06, center_atol=1e-06, bounding_box_atol=1e-06)¶
Export a DAGMC compatible h5m file for use in neutronics simulations. This method makes use of Gmsh to create a surface mesh of the geometry. MOAB is used to convert the meshed geometry into a h5m with parts tagged by using the reactor.shape_and_components.name properties. You will need Gmsh installed and MOAB installed to use this function. Acceptable tolerances may need increasing to match reactor parts with the parts in the intermediate Brep file produced during the process
- Parameters
filename – the filename of the DAGMC h5m file to write
min_mesh_size – the minimum mesh element size to use in Gmsh. Passed into gmsh.option.setNumber(“Mesh.MeshSizeMin”, min_mesh_size)
max_mesh_size – the maximum mesh element size to use in Gmsh. Passed into gmsh.option.setNumber(“Mesh.MeshSizeMax”, max_mesh_size)
exclude – A list of shape names to not include in the exported geometry. ‘plasma’ is often excluded as not many neutron interactions occur within a low density plasma.
volume_atol – the absolute volume tolerance to allow when matching parts in the intermediate brep file with the cadquery parts
center_atol – the absolute center coordinates tolerance to allow when matching parts in the intermediate brep file with the cadquery parts
bounding_box_atol – the absolute volume tolerance to allow when matching parts in the intermediate brep file with the cadquery parts
- Return type
str
- export_html(filename='reactor.html', facet_splines=True, facet_circles=True, tolerance=1.0, view_plane='RZ')¶
Creates a html graph representation of the points for the Shape objects that make up the reactor. Shapes are colored by their .color property. Shapes are also labelled by their .name. If filename provided doesn’t end with .html then .html will be added.
- Parameters
filename – the filename used to save the html graph. Defaults to reactor.html
facet_splines – If True then spline edges will be faceted. Defaults to True.
facet_circles – If True then circle edges will be faceted. Defaults to True.
tolerance – faceting toleranceto use when faceting cirles and splines. Defaults to 1e-3.
view_plane – The plane to project. Options are ‘XZ’, ‘XY’, ‘YZ’, ‘YX’, ‘ZY’, ‘ZX’, ‘RZ’ and ‘XYZ’. Defaults to ‘RZ’. Defaults to ‘RZ’.
- Returns
figure object
- Return type
plotly.Figure()
- export_html_3d(filename='reactor_3d.html', **kwargs)¶
Saves an interactive 3d html view of the Reactor to a html file.
- Parameters
filename – the filename used to save the html graph. Defaults to reactor_3d.html
kwargs – keyword arguments passed to jupyter-cadquery show() function. See https://github.com/bernhard-42/jupyter-cadquery#usage for more details on acceptable keywords
- Returns
filename of the created html file
- Return type
str
- Return type
Optional
[str
]
- export_stl(filename=None, tolerance=0.001, angular_tolerance=0.1)¶
Writes stl files (CAD geometry) for each Shape object in the reactor
- Parameters
filename – Accepts a single filename as a string which exports the full reactor model to a single file. Alternativley filename can also accept a list of strings where each string is the filename of the the individual shapes that make it up. This will result in separate files for each shape in the reactor. Defaults to None which uses the Reactor.name with ‘.stl’ appended to the end of each entry.
tolerance (float) – the precision of the faceting
include_graveyard – specify if the graveyard will be included or not. If True the the Reactor.make_graveyard will be called using Reactor.graveyard_size and Reactor.graveyard_offset attribute values.
- Returns
a list of stl filenames created
- Return type
list
- Return type
Union
[str
,List
[str
]]
- export_stp(filename=None, mode='solid', units='mm')¶
Exports the 3D reactor model as a stp file or files.
- Parameters
filename – Accepts a single filename as a string which exports the full reactor model to a single file. Alternativley filename can also accept a list of strings where each string is the filename of the the individual shapes that make it up. This will result in separate files for each shape in the reactor. Defaults to None which uses the Reactor.name with ‘.stp’ appended to the end of each entry.
mode – the object to export can be either ‘solid’ which exports 3D solid shapes or the ‘wire’ which exports the wire edges of the shape.
units – the units of the stp file, options are ‘cm’ or ‘mm’. Default is mm.
- Returns
The stp filename(s) created
- Return type
Union
[List
[str
],str
]
- export_stp_graveyard(filename='graveyard.stp', graveyard_size=None, graveyard_offset=None)¶
Writes a stp file (CAD geometry) for the reactor graveyard. This is needed for DAGMC simulations. This method also calls Reactor.make_graveyard() with the graveyard_size and graveyard_size values.
- Parameters
filename (str) – the filename for saving the stp file. Appends .stp to the filename if it is missing.
graveyard_size – directly sets the size of the graveyard. Defaults to None which then uses the Reactor.graveyard_size attribute.
graveyard_offset – the offset between the largest edge of the geometry and inner bounding shell created. Defaults to None which then uses Reactor.graveyard_offset attribute.
- Returns
the stp filename created
- Return type
str
- Return type
str
- export_svg(filename='reactor.svg', projectionDir=(- 1.75, 1.1, 5), width=1000, height=800, marginLeft=120, marginTop=100, strokeWidth=None, strokeColor=(0, 0, 0), hiddenColor=(100, 100, 100), showHidden=False, showAxes=False)¶
Exports an svg file for the Reactor.solid. If the filename provided doesn’t end with .svg it will be added.
- Parameters
filename – the filename of the svg file to be exported. Defaults to “reactor.svg”.
projectionDir – The direction vector to view the geometry from (x, y, z). Defaults to (-1.75, 1.1, 5)
width – the width of the svg image produced in pixels. Defaults to 1000
height – the height of the svg image produced in pixels. Defaults to 800
marginLeft – the number of pixels between the left edge of the image and the start of the geometry.
marginTop – the number of pixels between the top edge of the image and the start of the geometry.
strokeWidth – the width of the lines used to draw the geometry. Defaults to None which automatically selects an suitable width.
strokeColor – the color of the lines used to draw the geometry in RGB format with each value between 0 and 255. Defaults to (0, 0, 0) which is black.
hiddenColor – the color of the lines used to draw the geometry in RGB format with each value between 0 and 255. Defaults to (100, 100, 100) which is light grey.
showHidden – If the edges obscured by geometry should be included in the diagram. Defaults to False.
showAxes – If the x, y, z axis should be included in the image. Defaults to False.
- Returns
the svg filename created
- Return type
str
- Return type
str
- property largest_dimension¶
Calculates a bounding box for the Reactor and returns the largest absolute value of the largest dimension of the bounding box
- make_graveyard(graveyard_size=None, graveyard_offset=None)¶
Creates a graveyard volume (bounding box) that encapsulates all volumes. This is required by DAGMC when performing neutronics simulations. The graveyard size can be ascertained in two ways. Either the size can be set directly using the graveyard_size which is the quickest method. Alternativley the graveyard can be automatically sized to the geometry by setting a graveyard_offset value. If both options are set then the method will default to using the graveyard_size preferentially.
- Parameters
graveyard_size – directly sets the size of the graveyard. Defaults to None which then uses the Reactor.graveyard_size attribute.
graveyard_offset – the offset between the largest edge of the geometry and inner bounding shell created. Defaults to None which then uses Reactor.graveyard_offset attribute.
- Returns
a shell volume that bounds the geometry, referred to as a graveyard in DAGMC
- Return type
CadQuery solid
- Return type
- make_sector_wedge(height=None, radius=None, rotation_angle=None)¶
Creates a rotated wedge shaped object that is useful for creating sector models in DAGMC where reflecting surfaces are needed. If the rotation
- Parameters
height – The height of the rotated wedge. If None then the largest_dimension of the model will be used.
radius – The radius of the rotated wedge. If None then the largest_dimension of the model will be used
rotation_angle – The rotation angle of the wedge will be the inverse of the sector
- Returns
the paramak.Shape object created
- Return type
Optional
[Shape
]
- property name¶
Returns a list of names of the individual Shapes that make up the reactor
- property shapes_and_components¶
Adds a list of parametric shape(s) and or parametric component(s) to the Reactor object. This allows collective operations to be performed on all the shapes in the reactor.
- show(**kwargs)¶
Shows / renders the CadQuery the 3d object in Jupyter Lab. Imports show from jupyter_cadquery and returns show(Reactor.solid, kwargs)
- Parameters
kwargs – keyword arguments passed to jupyter-cadquery show() function. See https://github.com/bernhard-42/jupyter-cadquery#usage for more details on acceptable keywords
- Returns
jupyter_cadquery show object
- property solid¶
This combines all the parametric shapes and components in the reactor object.
- volume(split_compounds=False)¶
Get the volumes of the Shapes in the Reactor.
- Parameters
split_compounds – If the Shape is a compound of Shapes and therefore contains multiple volumes. This option allows access to the separate volumes of each component within a Shape (True) or the volumes of compounds can be summed (False).
- Returns
The the volumes of the Shapes
- Return type
List
[float
]