API Reference

mcio.surface

Surface classes used to build CSG half-spaces.

Defines the Surface base class and the concrete MCNP-style surface types (planes, spheres, cylinders, cones, quadrics and tori), together with helpers to write them as MCNP, Serpent and OpenMC surfaces, sort them, and map MCNP surface mnemonics to classes.

class mcio.surface.ConeOnXAxis(x0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone on the X-axis with vertex at (x0, 0, 0).

Parameters:
  • x0 (float, optional) – X-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone on X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ConeOnYAxis(y0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone on the Y-axis with vertex at (0, y0, 0).

Parameters:
  • y0 (float, optional) – Y-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone on Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ConeOnZAxis(z0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone on the Z-axis with vertex at (0, 0, z0).

Parameters:
  • z0 (float, optional) – Z-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone on Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ConeParallelToXAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone parallel to the X-axis with vertex at (x0, y0, z0).

Parameters:
  • x0 (float, optional) – X-coordinate of vertex, by default 0.0

  • y0 (float, optional) – Y-coordinate of vertex, by default 0.0

  • z0 (float, optional) – Z-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone parallel to X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ConeParallelToYAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone parallel to the Y-axis with vertex at (x0, y0, z0).

Parameters:
  • x0 (float, optional) – X-coordinate of vertex, by default 0.0

  • y0 (float, optional) – Y-coordinate of vertex, by default 0.0

  • z0 (float, optional) – Z-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone parallel to Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ConeParallelToZAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, t_sq: float = 0.0, sheet: int = 0, **kwargs: Any)

Bases: Surface

Cone parallel to the Z-axis with vertex at (x0, y0, z0).

Parameters:
  • x0 (float, optional) – X-coordinate of vertex, by default 0.0

  • y0 (float, optional) – Y-coordinate of vertex, by default 0.0

  • z0 (float, optional) – Z-coordinate of vertex, by default 0.0

  • t_sq (float, optional) – Tangent squared of cone half-angle, by default 0.0

  • sheet (int, optional) – Sheet selector (-1, 0, or 1), by default 0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cone parallel to Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderOnXAxis(radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder on the X-axis with radius r.

Parameters:
  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder on X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderOnYAxis(radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder on the Y-axis with radius r.

Parameters:
  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder on Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderOnZAxis(radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder on the Z-axis with radius r.

Parameters:
  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder on Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderParallelToXAxis(y0: float = 0.0, z0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder parallel to the X-axis centered at (y0, z0) with radius r.

Parameters:
  • y0 (float, optional) – Y-coordinate of cylinder axis, by default 0.0

  • z0 (float, optional) – Z-coordinate of cylinder axis, by default 0.0

  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder parallel to X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderParallelToYAxis(x0: float = 0.0, z0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder parallel to the Y-axis centered at (x0, z0) with radius r.

Parameters:
  • x0 (float, optional) – X-coordinate of cylinder axis, by default 0.0

  • z0 (float, optional) – Z-coordinate of cylinder axis, by default 0.0

  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder parallel to Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.CylinderParallelToZAxis(x0: float = 0.0, y0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Cylinder parallel to the Z-axis centered at (x0, y0) with radius r.

Parameters:
  • x0 (float, optional) – X-coordinate of cylinder axis, by default 0.0

  • y0 (float, optional) – Y-coordinate of cylinder axis, by default 0.0

  • radius (float, optional) – Radius of cylinder, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of cylinder parallel to Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.Ellipsoid(a: float = 0.0, b: float = 0.0, c: float = 0.0, d: float = 0.0, e: float = 0.0, f: float = 0.0, g: float = 0.0, x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, **kwargs: Any)

Bases: Surface

Ellipsoid surface.

Parameters:
  • a (float, optional) – Quadric equation coefficients, by default 0.0

  • b (float, optional) – Quadric equation coefficients, by default 0.0

  • c (float, optional) – Quadric equation coefficients, by default 0.0

  • d (float, optional) – Quadric equation coefficients, by default 0.0

  • e (float, optional) – Quadric equation coefficients, by default 0.0

  • f (float, optional) – Quadric equation coefficients, by default 0.0

  • g (float, optional) – Quadric equation coefficients, by default 0.0

  • x0 (float, optional) – Center point offset coordinates, by default 0.0

  • y0 (float, optional) – Center point offset coordinates, by default 0.0

  • z0 (float, optional) – Center point offset coordinates, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the ellipsoid.

class mcio.surface.GeneralQuadratic(a: float = 0.0, b: float = 0.0, c: float = 0.0, d: float = 0.0, e: float = 0.0, f: float = 0.0, g: float = 0.0, h: float = 0.0, j: float = 0.0, k: float = 0.0, **kwargs: Any)

Bases: Surface

General quadratic surface.

Parameters:
  • a (float, optional) – General quadratic surface coefficients, by default 0.0

  • b (float, optional) – General quadratic surface coefficients, by default 0.0

  • c (float, optional) – General quadratic surface coefficients, by default 0.0

  • d (float, optional) – General quadratic surface coefficients, by default 0.0

  • e (float, optional) – General quadratic surface coefficients, by default 0.0

  • f (float, optional) – General quadratic surface coefficients, by default 0.0

  • g (float, optional) – General quadratic surface coefficients, by default 0.0

  • h (float, optional) – General quadratic surface coefficients, by default 0.0

  • j (float, optional) – General quadratic surface coefficients, by default 0.0

  • k (float, optional) – General quadratic surface coefficients, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the general quadratic surface.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.Plane(a: float = 0.0, b: float = 0.0, c: float = 0.0, d: float = 0.0, **kwargs: Any)

Bases: Surface

General plane surface defined by the equation ax + by + cz = d.

Parameters:
  • a (float, optional) – Coefficient of x, by default 0.0

  • b (float, optional) – Coefficient of y, by default 0.0

  • c (float, optional) – Coefficient of z, by default 0.0

  • d (float, optional) – Displacement constant d, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the plane.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.PlaneFromThreePoints(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, x1: float = 0.0, y1: float = 0.0, z1: float = 0.0, x2: float = 0.0, y2: float = 0.0, z2: float = 0.0, **kwargs: Any)

Bases: Surface

Plane surface defined by three points in Cartesian coordinates.

Parameters:
  • x0 (float, optional) – Coordinates of the first point, by default 0.0

  • y0 (float, optional) – Coordinates of the first point, by default 0.0

  • z0 (float, optional) – Coordinates of the first point, by default 0.0

  • x1 (float, optional) – Coordinates of the second point, by default 0.0

  • y1 (float, optional) – Coordinates of the second point, by default 0.0

  • z1 (float, optional) – Coordinates of the second point, by default 0.0

  • x2 (float, optional) – Coordinates of the third point, by default 0.0

  • y2 (float, optional) – Coordinates of the third point, by default 0.0

  • z2 (float, optional) – Coordinates of the third point, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the plane.

class mcio.surface.Sphere(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

General sphere centered at (x0, y0, z0) with radius r.

Parameters:
  • x0 (float, optional) – X-coordinate of center, by default 0.0

  • y0 (float, optional) – Y-coordinate of center, by default 0.0

  • z0 (float, optional) – Z-coordinate of center, by default 0.0

  • radius (float, optional) – Radius of sphere, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the sphere.

property openmc_surface: Any

OpenMC surface object representation.

property serpent_card: SerpentCard

Serpent card representation of the sphere.

class mcio.surface.SphereAtOrigin(radius: float = 0.0, **kwargs: Any)

Bases: Surface

Sphere centered at the origin (0, 0, 0) with radius r.

Parameters:
  • radius (float, optional) – Radius of sphere, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the sphere at origin.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.SphereOnXAxis(x0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Sphere centered on the X-axis at (x0, 0, 0) with radius r.

Parameters:
  • x0 (float, optional) – X-coordinate of center, by default 0.0

  • radius (float, optional) – Radius of sphere, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the sphere on X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.SphereOnYAxis(y0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Sphere centered on the Y-axis at (0, y0, 0) with radius r.

Parameters:
  • y0 (float, optional) – Y-coordinate of center, by default 0.0

  • radius (float, optional) – Radius of sphere, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the sphere on Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.SphereOnZAxis(z0: float = 0.0, radius: float = 0.0, **kwargs: Any)

Bases: Surface

Sphere centered on the Z-axis at (0, 0, z0) with radius r.

Parameters:
  • z0 (float, optional) – Z-coordinate of center, by default 0.0

  • radius (float, optional) – Radius of sphere, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the sphere on Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.Surface(reflective: bool = False, comment: str | None = None, transform: Transform | None = None, openmc_graveyard: bool = False, number: int | None = None)

Bases: object

Base class for all surface types.

Parameters:
  • reflective (bool, optional) – Whether the surface is reflective, by default False

  • comment (str, optional) – Optional descriptive text associated with the surface, by default None

  • transform (Transform, optional) – Transform object to be applied to the surface, by default None

  • openmc_graveyard (bool, optional) – Flag indicating if the surface belongs to an OpenMC graveyard, by default False

  • number (int, optional) – Surface number assigned, by default None

classmethod from_mcnp_card(mcnp_card: str) → Surface

Construct a Surface object from an MCNP card string.

Parameters:

mcnp_card (str) – Raw MCNP surface card string

Returns:

Constructed surface instance

Return type:

Surface

class mcio.surface.ToriParralleltoXAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, a: float = 0.0, b: float = 0.0, c: float = 0.0, **kwargs: Any)

Bases: Surface

Torus parallel to the X-axis.

Parameters:
  • x0 (float, optional) – Center coordinates, by default 0.0

  • y0 (float, optional) – Center coordinates, by default 0.0

  • z0 (float, optional) – Center coordinates, by default 0.0

  • a (float, optional) – Radii parameters, by default 0.0

  • b (float, optional) – Radii parameters, by default 0.0

  • c (float, optional) – Radii parameters, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of torus parallel to X-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ToriParralleltoYAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, a: float = 0.0, b: float = 0.0, c: float = 0.0, **kwargs: Any)

Bases: Surface

Torus parallel to the Y-axis.

Parameters:
  • x0 (float, optional) – Center coordinates, by default 0.0

  • y0 (float, optional) – Center coordinates, by default 0.0

  • z0 (float, optional) – Center coordinates, by default 0.0

  • a (float, optional) – Radii parameters, by default 0.0

  • b (float, optional) – Radii parameters, by default 0.0

  • c (float, optional) – Radii parameters, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of torus parallel to Y-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ToriParralleltoZAxis(x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, a: float = 0.0, b: float = 0.0, c: float = 0.0, **kwargs: Any)

Bases: Surface

Torus parallel to the Z-axis.

Parameters:
  • x0 (float, optional) – Center coordinates, by default 0.0

  • y0 (float, optional) – Center coordinates, by default 0.0

  • z0 (float, optional) – Center coordinates, by default 0.0

  • a (float, optional) – Radii parameters, by default 0.0

  • b (float, optional) – Radii parameters, by default 0.0

  • c (float, optional) – Radii parameters, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of torus parallel to Z-axis.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.XPlane(x0: float = 0.0, **kwargs: Any)

Bases: Surface

Plane perpendicular to the X-axis at x = x0.

Parameters:
  • x0 (float, optional) – Location on the X-axis, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the X-plane.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.YPlane(y0: float = 0.0, **kwargs: Any)

Bases: Surface

Plane perpendicular to the Y-axis at y = y0.

Parameters:
  • y0 (float, optional) – Location on the Y-axis, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the Y-plane.

property openmc_surface: Any

OpenMC surface object representation.

class mcio.surface.ZPlane(z0: float = 0.0, **kwargs: Any)

Bases: Surface

Plane perpendicular to the Z-axis at z = z0.

Parameters:
  • z0 (float, optional) – Location on the Z-axis, by default 0.0

  • **kwargs (Any) – Keyword arguments passed to Surface (reflective, comment, transform, openmc_graveyard, number).

property mcnp_card: MCNPCard

MCNP card representation of the Z-plane.

property openmc_surface: Any

OpenMC surface object representation.

mcio.surface.mcnp_surface(surface_type: str, parameters: List[str], surface: Surface) → MCNPCard

Construct an MCNPCard representation for a surface.

Parameters:
  • surface_type (str) – The MCNP surface type designator string

  • parameters (list of str) – Parameters formatted as strings for the MCNP surface

  • surface (Surface) – The surface object being converted

Returns:

Constructed MCNP surface card

Return type:

MCNPCard

mcio.surface.openmc_boundary_type(surface: Surface) → str

Determine the OpenMC boundary type for a surface.

Parameters:

surface (Surface) – Surface object to check

Returns:

OpenMC boundary type string (‘vacuum’, ‘reflective’, or ‘transmission’)

Return type:

str

mcio.surface.serpent_surface(surface_type: str, parameters: List[str], surface: Surface) → SerpentCard

Construct a SerpentCard representation for a surface.

Parameters:
  • surface_type (str) – The Serpent surface type designator string

  • parameters (list of str) – Parameters formatted as strings for the Serpent surface

  • surface (Surface) – The surface object being converted

Returns:

Constructed Serpent surface card

Return type:

SerpentCard

mcio.volume

CSG volume and Boolean expression classes.

Contains HalfVolume (one side of a surface), the Boolean operators And (intersection) and Or (union), and Volume, which wraps a Boolean expression. These are exported to MCNP strings, OpenMC regions and Open CASCADE solids.

class mcio.volume.And(sub_booleans: list[Boolean | HalfVolume])

Bases: Boolean

Intersection of half volumes and/or other Booleans.

Nested And operands are flattened into this one, and duplicate half volumes are dropped.

Parameters:

sub_booleans (list[Boolean | HalfVolume]) – Operands of the intersection.

property mcnp_string: list[str]

MCNP geometry tokens for the intersection.

Sub-expressions that are lists are wrapped in parentheses.

ocp_solid(bounding_box: BoundingBox | None = None, decom_params: DecompositionParameters | None = None) → TopoDS_Shape

Build an Open CASCADE solid of the intersection.

Parameters:
  • bounding_box (BoundingBox, optional) – Bounds used to make half spaces finite, by default None (a +/-1000 box)

  • decom_params (DecompositionParameters, optional) – Decomposition parameters for the OCP Boolean operations, by default None (default parameters)

Returns:

Solid representing the intersection.

Return type:

TopoDS_Shape

property openmc_region: openmc.Region

OpenMC region formed by intersecting all sub-boolean regions.

class mcio.volume.Boolean

Bases: object

Base class for Boolean combinations of half volumes and other Booleans.

Sub-classes And and Or populate _sub_booleans.

replace_duplicate_surfaces(surfaces: dict[str, Surface]) → None

Replace duplicate surfaces in all sub-booleans with shared instances.

Parameters:

surfaces (dict[str, Surface]) – Map of surface hash string to the surface instance to keep; updated in place with newly seen surfaces.

property sub_booleans: list[Boolean | HalfVolume]

Sub-booleans and half volumes combined by this Boolean.

property surfaces: list[Surface | Macrobody]

All surfaces referenced by this Boolean, recursively (may repeat).

class mcio.volume.HalfVolume(direction: str, surface: Surface | Macrobody)

Bases: object

One side (half space) of a surface.

Usually created with the unary +/- operators on a surface.

Parameters:
  • direction (str) – '+' for the positive side of the surface, '-' for the negative.

  • surface (Surface or Macrobody) – The bounding surface.

property direction: str

Side of the surface, '+' or '-'.

property mcnp_string: str

MCNP token for the half volume (signed surface number).

ocp_solid(bounding_box: BoundingBox | None = None, decom_params: DecompositionParameters | None = None) → TopoDS_Shape

Build an Open CASCADE solid of the half space clipped to a box.

Parameters:
  • bounding_box (BoundingBox, optional) – Bounds used to make the half space finite, by default None (a +/-1000 box)

  • decom_params (DecompositionParameters, optional) – Decomposition parameters for the OCP Boolean operations, by default None (default parameters)

Returns:

Solid representing the bounded half space.

Return type:

TopoDS_Shape

property openmc_region: openmc.Halfspace

OpenMC half space for this side of the surface.

replace_duplicate_surfaces(surfaces: dict[str, Surface]) → None

Swap this half volume’s surface for an identical stored one.

Macrobodies are skipped. If no matching surface is stored, this surface is added to surfaces.

Parameters:

surfaces (dict[str, Surface]) – Map of surface hash string to the surface instance to keep; updated in place.

property surface: Surface | Macrobody

The bounding surface.

property surfaces: list[Surface | Macrobody]

List containing the single bounding surface.

property volume: float | None

Volume value stored on the half volume (read only redefinition).

class mcio.volume.Or(sub_booleans: list[Boolean | HalfVolume])

Bases: Boolean

Union of half volumes and/or other Booleans.

Nested Or operands are flattened into this one, and duplicate half volumes are dropped.

Parameters:

sub_booleans (list[Boolean | HalfVolume]) – Operands of the union.

property mcnp_string: list[str]

MCNP geometry tokens for the union, operands separated by :.

Sub-expressions that are lists are wrapped in parentheses.

ocp_solid(bounding_box: BoundingBox | None = None, decom_params: DecompositionParameters | None = None) → TopoDS_Shape

Build an Open CASCADE solid of the union.

Parameters:
  • bounding_box (BoundingBox, optional) – Bounds used to make half spaces finite, by default None (a +/-1000 box)

  • decom_params (DecompositionParameters, optional) – Decomposition parameters for the OCP Boolean operations, by default None (default parameters)

Returns:

Solid representing the union.

Return type:

TopoDS_Shape

property openmc_region: openmc.Region

OpenMC region formed by the union of all sub-boolean regions.

class mcio.volume.Volume(boolean: Boolean, volume: float | None = None)

Bases: object

CSG volume defined by a Boolean expression.

Parameters:
  • boolean (Boolean) – Boolean expression (or half volume) defining the region.

  • volume (float, optional) – Volume value associated with the region, by default None

property boolean: Boolean

Boolean expression defining the region.

property mcnp_string: list[str] | str

MCNP geometry tokens for the volume.

ocp_solid(bounding_box: BoundingBox | None = None, decom_params: DecompositionParameters | None = None) → TopoDS_Shape

Build an Open CASCADE solid of the volume.

Parameters:
  • bounding_box (BoundingBox, optional) – Bounds used to make half spaces finite, by default None (a +/-1000 box)

  • decom_params (DecompositionParameters, optional) – Decomposition parameters for the OCP Boolean operations, by default None (default parameters)

Returns:

Solid representing the volume.

Return type:

TopoDS_Shape

property openmc_region: openmc.Region

OpenMC region for the volume.

replace_duplicate_surfaces(surfaces: dict[str, Surface]) → None

Replace duplicate surfaces in the Boolean with shared instances.

Parameters:

surfaces (dict[str, Surface]) – Map of surface hash string to the surface instance to keep; updated in place.

property surfaces: list[Surface | Macrobody]

All surfaces referenced by the volume (may repeat).

property volume: float | None

Volume value associated with the region.

mcio.material

Material definitions for mcio.

Contains the Material class (a single material composition with MCNP, OpenMC and GDML output), the Materials collection, and helper functions for loading materials from json files and assigning them to solids from CAD colour or _mN_ structure labels.

class mcio.material.Material(density: float = 0.0, composition: dict[str, float] | None = None, fraction_type: str = 'ao', density_unit: str = 'g/cm3', name: str | None = None, reference: str | None = None, number: int | None = None)

Bases: SerialisableFromDict

A material defined by density and elemental/isotopic composition.

Composition keys may be element symbols (e.g. Li), isotopes (element symbol and mass number, e.g. Li6) or zaids as strings (e.g. 3006).

Parameters:
  • density (float, optional) – Material density, by default 0.0

  • composition (dict[str, float], optional) – Mapping of element, isotope or zaid to fraction, by default None (empty composition)

  • fraction_type (str, optional) – 'ao' for atom fractions or 'wo' for weight fractions, by default ‘ao’

  • density_unit (str, optional) – One of 'g/cc', 'g/cm3' or 'atoms/barn-cm', by default ‘g/cm3’

  • name (str, optional) – Material name, by default None

  • reference (str, optional) – Reference / source of the material data, by default None

  • number (int, optional) – Material number, by default None

Raises:

Exception – If fraction_type or density_unit is not recognised.

property elements: list[str]

Composition keys that are elements.

Returns:

Element symbols present directly in the composition.

Return type:

list[str]

from_mcnp_card(mcnp_card: str) → Material

Create a material from an MCNP card (not yet implemented).

Parameters:

mcnp_card (str) – MCNP material card string.

Returns:

Currently returns None, as parsing is not implemented.

Return type:

Material

property gdml_xml_tag: XMLTag

GDML material XML tag (currently with no attributes or children).

Returns:

Empty GDML material tag.

Return type:

XMLTag

property isotopes: list[str]

Composition keys that are isotopes.

Returns:

Isotopes (e.g. Li6) present directly in the composition.

Return type:

list[str]

property mcnp_card: MCNPCard

Generate an MCNP material card from the material composition.

Returns:

The MCNP material card (with an MT sub-card if S(a,b) cards are set).

Return type:

MCNPCard

Raises:

TypeError – TypeError raised if composition contains entrance that is neither an element (as one or two letter symbol, e.g. Li), isotopes (as symbol and numeric value as mass number, e.g. Li6) or zaid (4-6 integer long numeric of the atomic number and mass number, e.g. 3006, 03006 or 003006).

property openmc_material: openmc.Material

OpenMC material equivalent of this material, created on first use.

Returns:

Cached OpenMC material with density in g/cc.

Return type:

openmc.Material

property serpent2_card: None

Serpent2 material card (not yet implemented).

Returns:

Always None.

Return type:

None

strip_isotopes(isotopes_to_strip: list[str]) → None

Replace the composition with its isotopes, excluding those given.

Elements and zaids are expanded to isotopes first (see _combine_isotopes()).

Parameters:

isotopes_to_strip (list[str]) – Isotopes to remove (e.g. those missing from ADVANTG libraries).

class mcio.material.Materials(materials: list[Material])

Bases: object

Collection of materials.

Parameters:

materials (list[Material]) – Materials in the collection.

property elements: list[str]

Elements appearing directly in any material composition.

Returns:

Element symbols, in order of appearance (duplicates are not removed).

Return type:

list[str]

property gdml_xml_tag: XMLTag

GDML materials XML tag containing isotope and element tags.

Returns:

Materials tag with an isotope child per isotope and an element child per element.

Return type:

XMLTag

property isotopes: list[str]

Isotopes appearing directly in any material composition.

Returns:

Isotopes, in order of appearance (duplicates are not removed).

Return type:

list[str]

property materials: list[Material]

Materials in the collection.

Returns:

The materials.

Return type:

list[Material]

mcio.material.openmc_material_to_mcio_material(material_openmc: openmc.Material) → Material

Convert an OpenMC material into an mcio material.

Parameters:

material_openmc (openmc.Material) – OpenMC material with nuclides all of the same fraction type and density in g/cc, g/cm3 or kg/m3.

Returns:

Equivalent mcio material, with density in g/cm3.

Return type:

Material

Raises:

ValueError – If the material has no nuclides, mixed fraction types, or an unsupported density unit.

mcio.tally

Tally definitions for MCNP and OpenMC output.

Contains the Tally base class, cell/surface tallies (current, surface and volume fluence, energy deposition, pulse height) and a regular mesh fluence tally, each able to produce an MCNP card and an OpenMC tally.

class mcio.tally.CellOrSurfaceTally(cells: list[Cell] | None = None, surfaces: list[Surface] | None = None, comment: str | None = None, **kwargs: Any)

Bases: Tally

Base class for tallies over a list of cells or surfaces.

Parameters:
  • cells (list[Cell], optional) – Cells to tally over, by default None

  • surfaces (list[Surface], optional) – Surfaces to tally over (used only if no cells are given), by default None

  • comment (str, optional) – Tally comment, by default None

  • **kwargs (Any) – Passed to Tally.

property mcnp_card: MCNPCard

MCNP tally card with its sub-cards.

Includes cell/surface flag, comment, energy, multiplier, divisor and dose function (DE/DF) cards where set.

Raises:

Exception – If dose_conversion_factors is not a two-item list, tuple or ndarray.

property openmc_tally: openmc.Tally

OpenMC tally with particle, cell/surface, energy and dose filters.

Energies are converted from MeV to eV.

Raises:

Exception – If neither cells nor surfaces are set, or if dose_conversion_factors is badly formatted.

property target_numbers: list[str]

Cell (or, if no cells, surface) numbers as strings.

Raises:

Exception – If neither cells nor surfaces are set.

class mcio.tally.EnergyDepositionTally(**kwargs: Any)

Bases: CellOrSurfaceTally

Energy deposition tally (MCNP F6, OpenMC heating).

Parameters:

**kwargs (Any) – Passed to CellOrSurfaceTally.

class mcio.tally.FluenceMeshTally(x_min: float = 0, x_max: float = 1, y_min: float = 0, y_max: float = 1, z_min: float = 0, z_max: float = 1, x_ints: int | list[int] = 1, y_ints: int | list[int] = 1, z_ints: int | list[int] = 1, **kwargs: Any)

Bases: Tally

Regular Cartesian mesh fluence tally (MCNP FMESH, OpenMC mesh filter).

Parameters:
  • x_min (float, optional) – Lower x bound of the mesh, by default 0

  • x_max (float, optional) – Upper x bound of the mesh, by default 1

  • y_min (float, optional) – Lower y bound of the mesh, by default 0

  • y_max (float, optional) – Upper y bound of the mesh, by default 1

  • z_min (float, optional) – Lower z bound of the mesh, by default 0

  • z_max (float, optional) – Upper z bound of the mesh, by default 1

  • x_ints (int or list[int], optional) – Number of mesh intervals in x, by default 1

  • y_ints (int or list[int], optional) – Number of mesh intervals in y, by default 1

  • z_ints (int or list[int], optional) – Number of mesh intervals in z, by default 1

  • **kwargs (Any) – Passed to Tally.

classmethod from_bounding_box(bounding_box: BoundingBox, resolution: float, extension: float, **kwargs) → FluenceMeshTally
property mcnp_card: MCNPCard

MCNP FMESH card with comment, dose function and multiplier sub-cards.

Raises:

Exception – If dose_conversion_factors is not a two-item list, tuple or ndarray.

property openmc_tally: openmc.Tally

OpenMC tally on a regular mesh with particle, energy and dose filters.

Only the first entry of each of x_ints, y_ints and z_ints is used for the mesh dimension. Energies are converted from MeV to eV.

Raises:

Exception – If dose_conversion_factors is badly formatted.

class mcio.tally.PulseHeightTally(**kwargs: Any)

Bases: CellOrSurfaceTally

Pulse height tally (MCNP F8, OpenMC pulse-height).

Parameters:

**kwargs (Any) – Passed to CellOrSurfaceTally.

class mcio.tally.SurfaceCurrent(**kwargs: Any)

Bases: CellOrSurfaceTally

Surface current tally (MCNP F1, OpenMC current).

Parameters:

**kwargs (Any) – Passed to CellOrSurfaceTally.

class mcio.tally.SurfaceFluenceTally(**kwargs: Any)

Bases: CellOrSurfaceTally

Surface fluence tally (MCNP F2, OpenMC flux).

Parameters:

**kwargs (Any) – Passed to CellOrSurfaceTally.

class mcio.tally.Tally(energies: list[float] | None = None, dose_conversion_factors: list[list[float]] | ndarray | None = None, comment: str | None = None, particles: list[str] = ['neutron'])

Bases: object

Base class for all tallies.

Parameters:
  • energies (list[float], optional) – Energy bin boundaries in MeV, by default None

  • dose_conversion_factors (list[list[float]], optional) – Pair [energies, factors] defining an energy-dependent response function (energies in MeV), by default None

  • comment (str, optional) – Tally comment, also used as the OpenMC tally name, by default None

  • particles (list[str], optional) – Particle names to tally, by default [‘neutron’]

classmethod from_dict(tally_type_label: str, tally_data: dict[str, Any]) → Tally

Construct a tally of the named type from a dictionary of arguments.

Parameters:
  • tally_type_label (str) – Tally type key, e.g. 'volumefluencetally'.

  • tally_data (dict[str, Any]) – Keyword arguments passed to the tally constructor.

Returns:

The constructed tally.

Return type:

Tally

Raises:

KeyError – If tally_type_label is not a known tally type.

class mcio.tally.VolumeFluenceTally(**kwargs: Any)

Bases: CellOrSurfaceTally

Cell volume fluence tally (MCNP F4, OpenMC flux).

Parameters:

**kwargs (Any) – Passed to CellOrSurfaceTally.

mcio.source

Particle source definitions for MCNP output.

Contains energy and position distributions and source classes (point, spherical stochastic volume, rectangular volume, cylindrical volume, circular plane and read-from-file) that write MCNP SDEF / READ cards.

class mcio.source.CircularPlaneParrallel(x0: float = 0, y0: float = 0, z0: float = 0, u0: float = 0, v0: float = 0, w0: float = 0, radius: float = 0.0, **kwargs: Any)

Bases: Source

Mono-directional disc source emitting along its axis.

Parameters:
  • x0 (float, optional) – x coordinate of the disc centre, by default 0

  • y0 (float, optional) – y coordinate of the disc centre, by default 0

  • z0 (float, optional) – z coordinate of the disc centre, by default 0

  • u0 (float, optional) – x component of the disc axis and emission direction, by default 0

  • v0 (float, optional) – y component of the disc axis and emission direction, by default 0

  • w0 (float, optional) – z component of the disc axis and emission direction, by default 0

  • radius (float, optional) – Disc radius, by default 0.0

  • **kwargs (Any) – Passed to Source (energy, particle).

property mcnp_card: MCNPCard

MCNP SDEF disc source card with radial (D2) sub-cards.

class mcio.source.IsotropicCylindricalVolume(x0: float = 0, y0: float = 0, z0: float = 0, u0: float = 0, v0: float = 0, w0: float = 0, radius: float = 0.0, height: float = 0.0, energy: float | SourceEnergyDistribution = 0.0, **kwargs: Any)

Bases: Source

Isotropic source uniformly distributed in a cylinder.

Parameters:
  • x0 (float, optional) – x coordinate of the base centre, by default 0

  • y0 (float, optional) – y coordinate of the base centre, by default 0

  • z0 (float, optional) – z coordinate of the base centre, by default 0

  • u0 (float, optional) – x component of the cylinder axis, by default 0

  • v0 (float, optional) – y component of the cylinder axis, by default 0

  • w0 (float, optional) – z component of the cylinder axis, by default 0

  • radius (float, optional) – Cylinder radius, by default 0.0

  • height (float, optional) – Cylinder height along the axis, by default 0.0

  • energy (float or SourceEnergyDistribution, optional) – Source energy in MeV or an energy distribution, by default 0.0

  • **kwargs (Any) – Passed to Source (particle).

property mcnp_card: MCNPCard

MCNP SDEF card with radial (D2) and axial extent (D3) sub-cards.

class mcio.source.MCNPSourceFromFile(file_path: str)

Bases: object

Source read from an external file via the MCNP READ card.

Parameters:

file_path (str) – Path of the file containing the source definition.

property file_path: str

Path of the source file.

property mcnp_card: MCNPCard

MCNP READ file= card.

class mcio.source.Point(position: tuple[float, float, float] | SourcePositionDistribution = (0, 0, 0), **kwargs: Any)

Bases: Source

Point source.

Parameters:
  • position (tuple[float, float, float] or SourcePositionDistribution, optional) – Source position or position distribution, by default (0, 0, 0)

  • **kwargs (Any) – Passed to Source (energy, particle).

property mcnp_card: MCNPCard

MCNP SDEF card with energy (D1) and position (D2) distributions.

property position: tuple[float, float, float] | SourcePositionDistribution

Source position or position distribution.

class mcio.source.RectangularParallelepipedVolume(x_min: float = 0.0, x_max: float = 0.0, y_min: float = 0.0, y_max: float = 0.0, z_min: float = 0.0, z_max: float = 0.0, direction: tuple[float, float, float] = (1, 0, 0), **kwargs: Any)

Bases: Source

Uniform source in an axis-aligned box, mono-directional.

Parameters:
  • x_min (float, optional) – Lower x bound, by default 0.0

  • x_max (float, optional) – Upper x bound, by default 0.0

  • y_min (float, optional) – Lower y bound, by default 0.0

  • y_max (float, optional) – Upper y bound, by default 0.0

  • z_min (float, optional) – Lower z bound, by default 0.0

  • z_max (float, optional) – Upper z bound, by default 0.0

  • direction (tuple[float, float, float], optional) – Emission direction vector (VEC), by default (1, 0, 0)

  • **kwargs (Any) – Passed to Source (energy, particle).

property mcnp_card: MCNPCard

MCNP SDEF card with x/y/z range distributions (D3-D5).

Degenerate axes are written as fixed coordinates instead of distributions.

class mcio.source.Source(energy: float | SourceEnergyDistribution = 1.0, particle: str = 'neutron')

Bases: object

Base class for particle sources.

Parameters:
  • energy (float or SourceEnergyDistribution, optional) – Mono-energetic source energy in MeV or an energy distribution, by default 1.0

  • particle (str, optional) – Source particle name, by default ‘neutron’

property energy: float | SourceEnergyDistribution

Source energy in MeV or energy distribution.

property particle: str

Source particle name.

class mcio.source.SourceEnergyDistribution(energies: list[float] = [0.0], distribution: list[float] = [1.0], distribution_type: str = 'discrete')

Bases: object

Source energy distribution written as MCNP SI1/SP1 cards.

Parameters:
  • energies (list[float], optional) – Energy values in MeV, by default [0.0]

  • distribution (list[float], optional) – Probabilities for each energy, by default [1.0]

  • distribution_type (str, optional) – 'discrete' (SI L) or 'histogram' (SI H), by default ‘discrete’

property mcnp_subcards: list[MCNPCard]

MCNP SI1 and SP1 cards for the distribution.

class mcio.source.SourcePositionDistribution(positions: list[tuple[float, float, float]], distribution: list[float], distribution_type: str = 'discrete')

Bases: object

Source position distribution written as MCNP SI2/SP2 cards.

Parameters:
  • positions (list[tuple[float, float, float]]) – Source positions (x, y, z).

  • distribution (list[float]) – Probabilities for each position.

  • distribution_type (str, optional) – 'discrete' (SI L) or 'histogram' (SI H), by default ‘discrete’

property mcnp_subcards: list[MCNPCard]

MCNP SI2 and SP2 cards for the distribution.

class mcio.source.SphericalStochasticVolumeSource(spherical_surface: Surface, particle: str = 'neutron', **kwargs: Any)

Bases: Source

Inward-directed surface source on a sphere for stochastic volume calculation.

Particles start on the spherical surface with a cosine-weighted inward direction; the weight is set to the sphere’s cross-sectional area.

Parameters:
  • spherical_surface (Surface) – Sphere surface (must have number and radius).

  • particle (str, optional) – Source particle name, by default ‘neutron’

  • **kwargs (Any) – Passed to Source (energy).

property mcnp_card: MCNPCard

MCNP SDEF surface source card with energy and direction sub-cards.

mcio.cell

Cell definition for MCIO geometry models.

Contains the Cell class, which combines a CSG volume with a material and optional universe/transform information, and exports to MCNP and OpenMC.

class mcio.cell.Cell(volume: Volume = None, material: Material = None, name: str = None, structure: list[str] = None, comment: str = None, transform: Transform = None, universe: Universe = None, universe_fill: UniverseFill = None, graveyard: bool = False, mcnp_cell_parameters: MCNPCellParameters = None)

Bases: object

Cell representation for geometry modeling and export to MCNP and OpenMC.

property material: Material

Material assigned to the cell.

property mcnp_card: MCNPCard

Generate the corresponding MCNP cell card definition.

Returns:

MCNP cell card object

Return type:

MCNPCard

ocp_solid(bounding_box: BoundingBox, decom_params: DecompositionParameters) → TopoDS_Shape

Generate Open CASCADE CAD solid for the cell volume.

Parameters:
  • bounding_box (BoundingBox) – Bounding box constraint for the solid generation

  • decom_params (DecompositionParameters) – Decomposition parameters for CAD construction

Returns:

Open CASCADE shape representing the transformed cell solid

Return type:

TopoDS_Shape

property openmc_cell: openmc.cell.Cell

Generate or retrieve the corresponding OpenMC cell object.

Returns:

Constructed OpenMC cell

Return type:

openmc.cell.Cell

property surfaces: list[Surface] | None

Surfaces bounding the cell volume, or None if no volume is set.

mcio.model

The mcio Model: a collection of cells with tallies, source and run settings.

Contains the Model class, which numbers cells, surfaces, materials, transforms, universes and tallies, and writes the geometry as MCNP, Serpent2, OpenMC or GDML input.

class mcio.model.Model(cells: list[Cell] | None = None, tallies: list[Tally] | None = None, source: Source | None = None, mcnp_run_parameters: MCNPRunParameters | None = None, cell_number_min: int | None = None, surface_number_min: int | None = None, tally_number_min: int | None = None, keep_surface_numbers: bool = True, keep_cell_numbers: bool = True, summary_data: dict[str, Any] | None = None)

Bases: object

A model made of cells, with tallies, a source and run parameters.

On creation, unique surfaces, macrobodies, materials, transforms and universes are collected from the cells and all items are numbered.

Parameters:
  • cells (list[Cell], optional) – Cells in the model, by default None

  • tallies (list[Tally], optional) – Tallies in the model, by default None (no tallies)

  • source (Source, optional) – Particle source, by default None (a default Point source)

  • mcnp_run_parameters (MCNPRunParameters, optional) – MCNP run parameters, by default None (default MCNPRunParameters)

  • cell_number_min (int, optional) – Lowest cell number to assign, by default None (1)

  • surface_number_min (int, optional) – Lowest surface number to assign, by default None (1)

  • tally_number_min (int, optional) – Lowest tally number to assign, by default None (1)

  • keep_surface_numbers (bool, optional) – Stored flag for keeping existing surface numbers (currently unused), by default True

  • keep_cell_numbers (bool, optional) – Stored flag for keeping existing cell numbers (currently unused), by default True

  • summary_data (dict[str, Any], optional) – Extra label/value pairs for the MCNP summary header, by default None

add_cells(cells: list[Cell]) → None

Add cells to the model and renumber everything.

Parameters:

cells (list[Cell]) – Cells to add.

add_material(material: Material) → None

Add a material to the model output

Parameters:

material (Material) – The material to be added to the model.

add_materials(materials: Any) → None

Add materials to the model and renumber.

Parameters:

materials (Any) – Materials to add with += to the internal material dictionary.

property cell_number_min: int

Lowest cell number assigned.

Returns:

Minimum cell number.

Return type:

int

property gdml_string: str

Model as GDML text (currently materials only).

Returns:

GDML xml string.

Return type:

str

property materials: Materials

Materials collected from the model cells.

Returns:

Collection wrapping the internal material dictionary.

Return type:

Materials

property mcnp_string: str

Model as MCNP input text.

Also updates the summary data with creation date/time and cell and surface counts.

Returns:

The full MCNP input.

Return type:

str

property openmc_model: openmc.model.Model

OpenMC model of the geometry, created on first use and cached.

Uses default settings (fixed source, 10 batches, 1e7 particles, a 1 MeV point source near the origin) and the model tallies.

Returns:

The OpenMC model.

Return type:

openmc.model.Model

property serpent_string: str

Model surfaces and cells as Serpent2 input text.

Returns:

Serpent2 surface and cell definitions.

Return type:

str

property surface_number_min: int

Lowest surface number assigned.

Returns:

Minimum surface number.

Return type:

int

property tallies: list[Tally]

Tallies in the model.

Returns:

The tallies.

Return type:

list[Tally]

write_gdml(output_filename: str | PathLike) → None

Write the model as a GDML file.

Parameters:

output_filename (str | os.PathLike) – Output file path.

write_mcnp(filepath: str | PathLike = 'output/model.i') → None

Write the model as an MCNP input file.

The parent folder of filepath is created if it does not exist.

Parameters:

filepath (str | os.PathLike, optional) – Output file path, by default ‘output/model.i’

write_openmc(output_folder: str | PathLike = 'output/openmc') → None

Export the OpenMC model as xml files.

Parameters:

output_folder (str | os.PathLike, optional) – Output folder, by default ‘output/openmc’

write_serpent(output_filename: str | PathLike) → None

Write the model as a Serpent2 input file.

Parameters:

output_filename (str | os.PathLike) – Output file path.

mcio.mcnp

MCNP card building and MCNP-specific parameter classes.

Contains classes that build MCNP input text (MCNPHeader, MCNPCardHeader, MCNPCard) and the MCNP parameter containers attached to models, tallies, cells and materials (MCNPRunParameters, MCNPTallyParameters, MCNPCellParameters, MCNPMaterialParameters).

class mcio.mcnp.MCNPCard(designator: str | int, rows: list[list[str]], subcards: list[MCNPCard] | None = None, header_data: dict[str, Any] | None = None)

Bases: object

A generic MCNP card made of a designator and rows of entries.

Entries are wrapped onto continuation lines (indented by formatting.MCNP_INDENT) so lines stay below formatting.MCNP_MAX_CHARS. Each row starts on a new line.

Parameters:
  • designator (str or int) – Card name or number written first (e.g. 'M1', 'NPS' or a cell number).

  • rows (list[list[str]]) – Rows of string entries.

  • subcards (list[MCNPCard], optional) – Cards written directly after this card, by default None

  • header_data (dict[str, Any], optional) – Data written as comment lines above the card, by default None

add_row(row: list[str]) → None

Append a row of entries to the card.

Parameters:

row (list[str]) – Entries of the row.

add_subcard(subcard: MCNPCard) → None

Append a sub-card, written after this card.

Parameters:

subcard (MCNPCard) – Card to append.

property as_string: str

Card (with header comments and sub-cards) as MCNP input text.

Returns:

The formatted card.

Return type:

str

class mcio.mcnp.MCNPCardHeader(data: dict[str, Any])

Bases: object

Comment lines written above an MCNP card.

Parameters:

data (dict[str, Any]) – Key/value pairs, each written as a C key: value comment line.

property as_string: str

Header as MCNP comment lines.

Returns:

Comment lines bracketed by blank C lines.

Return type:

str

class mcio.mcnp.MCNPCellParameters(graveyard: bool = False, importances: dict[str, float] | None = None, volume: float | None = None)

Bases: object

MCNP-specific cell options.

Parameters:
  • graveyard (bool, optional) – Whether the cell is a graveyard; if True all importances are set to zero, by default False

  • importances (dict[str, float], optional) – Importance per particle name, by default None (1.0 for neutron, photon and electron)

  • volume (float, optional) – Manually assigned cell volume written as VOL, by default None

property graveyard: bool

Whether the cell is a graveyard.

Returns:

Graveyard flag.

Return type:

bool

property importances: dict[str, float]

Importance per particle name.

Returns:

Particle importances.

Return type:

dict[str, float]

property volume: float | None

Manually assigned cell volume.

Returns:

Cell volume.

Return type:

float or None

class mcio.mcnp.MCNPHeader(header: str, data_pairs: dict[str, Any] | None = None, banner: list[str] | None = None)

Bases: object

MCNP section header written as a block of comment lines.

Produces a banner of C === comment lines containing the header title and, optionally, a list of label/value pairs.

Parameters:
  • header (str) – Title written in the banner.

  • data_pairs (dict[str, Any], optional) – Label/value pairs written under the title, by default None

  • banner (list[str], optional) – Banner lines (stored but currently unused), by default None

property as_string: str

Header as MCNP comment lines.

Float values below 1e-4 are written in scientific notation, other floats with four decimal places.

Returns:

Comment block, terminated with a newline.

Return type:

str

class mcio.mcnp.MCNPMaterialParameters

Bases: SerialisableFromDict

MCNP-specific material options, serialisable to/from a dictionary.

sab_cards

S(a,b) table identifiers written to the MT card.

Type:

list[str]

libs

Particle-dependent library per particle designator (e.g. PLIB).

Type:

dict[str, str]

property library: str

Default library suffix appended to each zaid (e.g. .80c).

Returns:

Library suffix, or an empty string if unset.

Return type:

str

property library_by_isotope: dict[str, str] | None

Library suffix overrides per isotope.

Returns:

Isotope to library suffix mapping.

Return type:

dict[str, str] or None

class mcio.mcnp.MCNPRunParameters(modes: list[str] = ['neutron'], nps: int = 1000000000.0, prdmp_intervals: int = 10, lost: int = 100, write_mctal: bool = True, xsdir: str | None = None, cut_parameters: dict[str, dict[str, float]] | None = None, physics_cards: list[str] | None = None, stop_tallies: dict[Tally, float] | None = None, weight_window: dict[str, list[float]] | None = None, idums: list[int] | None = None, rdums: list[float] | None = None, spabi: dict[str, dict[str, Any]] | None = None, forced_collisions: dict[str, dict[Cell, float]] | None = None, void: bool = False)

Bases: object

MCNP run control parameters (NPS, MODE, PHYS, CUT, etc.).

Parameters:
  • modes (list[str], optional) – Transported particle names (keys of MCNP_PARTICLE_DESIGNATORS), by default [‘neutron’]

  • nps (int, optional) – Number of particle histories, by default 1e9

  • prdmp_intervals (int, optional) – Number of dump intervals over the run used for the PRDMP card, by default 10

  • lost (int, optional) – Maximum number of lost particles, by default 100

  • write_mctal (bool, optional) – Whether to write an MCTAL file, by default True

  • xsdir (str, optional) – XSDIR path written to the MESSAGE block, by default None

  • cut_parameters (dict[str, dict[str, float]], optional) – CUT card values per particle name, by default None

  • physics_cards (list[str], optional) – Particle names for which PHYS cards are written, by default None

  • stop_tallies (dict[Tally, float], optional) – STOP card relative error cutoff per tally, by default None

  • weight_window (dict[str, list[float]], optional) – WWP card values per particle designator, by default None

  • idums (list[int], optional) – IDUM card values, by default None

  • rdums (list[float], optional) – RDUM card values, by default None

  • spabi (dict[str, dict[str, Any]], optional) – SPABI card data per secondary particle, with keys primary_particles, energies and multipliers, by default None

  • forced_collisions (dict[str, dict[Cell, float]], optional) – FCL card weighting per cell for each particle, by default None

  • void (bool, optional) – Whether to write a VOID card, by default False

property forced_collisions: dict[str, dict[Cell, float]] | None

FCL card weighting per cell for each particle.

Returns:

Forced collision data.

Return type:

dict[str, dict[Cell, float]] or None

property lost: int

Maximum number of lost particles.

Returns:

Lost particle limit.

Return type:

int

property mcnp_card: MCNPCard

Run parameter cards as an NPS card with sub-cards.

Sub-cards include PRDMP, MODE, LOST and, where set, VOID, PHYS, CUT, STOP, WWP, IDUM, RDUMS, SPABI and FCL.

Returns:

The NPS card with the other run cards as sub-cards.

Return type:

MCNPCard

property messages: list[MCNPCard]

MCNP MESSAGE block cards.

Returns:

A MESSAGE: card with the XSDIR, if set, else empty.

Return type:

list[MCNPCard]

property modes: list[str]

Transported particle names.

Returns:

Particle names.

Return type:

list[str]

property nps: int

Number of particle histories.

Returns:

Number of histories.

Return type:

int

property physics_particles: list[str]

Particle names for which PHYS cards are written.

Returns:

Particle names.

Return type:

list[str]

property secondary_particle_biasing: dict[str, dict[str, Any]] | None

SPABI card data per secondary particle.

Returns:

Secondary particle biasing data.

Return type:

dict[str, dict[str, Any]] or None

property stop_tallies: dict[Tally, float]

STOP card relative error cutoff per tally.

Returns:

Tally to cutoff mapping.

Return type:

dict[Tally, float]

property xsdir: str | None

XSDIR path written to the MESSAGE block.

Returns:

XSDIR path.

Return type:

str or None

class mcio.mcnp.MCNPTallyParameters(tally_divisor: float | list[float] | None = None, multiplier: float | None = None, cell_flags: list[Cell] | None = None, surface_flags: list[Surface] | None = None, dose_interpolation: str = 'log-log')

Bases: object

MCNP-specific tally options.

Parameters:
  • tally_divisor (float or list[float], optional) – Tally divisor (SD card), either a single value or one per target, by default None

  • multiplier (float, optional) – Tally multiplier, by default None

  • cell_flags (list[Cell], optional) – Cells used for cell flagging (CF card), by default None

  • surface_flags (list[Surface], optional) – Surfaces used for surface flagging (SF card), by default None

  • dose_interpolation (str, optional) – Interpolation for dose functions, by default ‘log-log’

property cell_flags: list[Cell] | None

Cells used for cell flagging.

Returns:

Flagged cells.

Return type:

list[Cell] or None

property dose_interpolation: str

Interpolation for dose functions.

Returns:

Interpolation scheme, e.g. ‘log-log’.

Return type:

str

property multiplier: float | None

Tally multiplier.

Returns:

Multiplier.

Return type:

float or None

property surface_flags: list[Surface] | None

Surfaces used for surface flagging.

Returns:

Flagged surfaces.

Return type:

list[Surface] or None

property tally_divisor: float | list[float] | None

Tally divisor, a single value or one per target.

Returns:

Tally divisor.

Return type:

float or list[float] or None

mcio.decomposeparams

Store the decomposition parameters used in the decompose module and OCP operations.

Contains the DecompositionParameters slots dataclass which holds every tolerance, flag, rounding precision and debugging path used during CAD to CSG decomposition, together with a human-readable definition of each parameter.

class mcio.decomposeparams.DecompositionParameters(doc_unit_in_metres: float = 0.01, doc_xcaf_formatting: str = 'BinXCAF', _def_doc_unit_in_metres: str = 'input unit length (m)', _def_doc_xcaf_formatting: str = 'XCAF Formatting', presplit_pipes: bool = True, presplit_pipes_cyl_angle_tol: float = 0.01, presplit_concentril_2nd_order: bool = True, presplit_about_axis: str = 'z', presplit_about_axis_n_times: int = 4, presplit_rectilinear_voxels: bool = False, presplit_rectilinear_voxels_width: float = 50.0, _def_presplit_pipes: str = 'pre-split: use pipe splitting tools for connected cylinders of equal radius', _def_presplit_pipes_cyl_angle_tol: str = 'pre-split on pipe cylinders: angle tolerance', _def_presplit_concentril_2nd_order: str = 'pre-split: split connected 2nd order surfaces which are on the same axix with circular edge', _def_presplit_about_axis: str = 'pre-split: split using planes about axis, either x, y or z', _def_presplit_about_axis_n_times: str = 'pre-split: number of planes about axis to split, n * 2 = segments, e.g. 4 = 8 octants', _def_presplit_rectilinear_voxels: str = 'pre-split: split all solids using a rectilinear grid', _def_presplit_rectilinear_voxels_width: str = 'pre-split: width of voxels in rectilinear grid split', cleanup_unify_same_domains: bool = False, cleanup_shape_fix: bool = False, cleanup_shape_fix_tol_min: float = 1e-08, cleanup_shape_fix_tol_max: float = 1e-06, cleanup_inexact_edges: bool = False, cleanup_inexact_edges_tol: float = 0.0001, cleanup_inexact_edge_fix_tol_min: float = 1e-08, cleanup_inexact_edge_fix_tol_max: float = 1e-06, _def_cleanup_unify_same_domains: str = 'unify domains can reduce number of preiodic boundaries', _def_cleanup_shape_fix: str = 'apply clean up using ShapeFix_Solid before decomposition', _def_cleanup_shape_fix_tol_min: str = 'ShapeFix_ShapeTolerance minimum tolerance', _def_cleanup_shape_fix_tol_max: str = 'ShapeFix_ShapeTolerance maximum tolerance', _def_cleanup_inexact_edges: str = 'check for inexact edges and cleanup with tolerance bounds', _def_cleanup_inexact_edges_tol: str = 'threshold tolerance for inexact edge fix', _def_cleanup_inexact_edge_fix_tol_min: str = 'inexact edges minimum tolerance', _def_cleanup_inexact_edge_fix_tol_max: str = 'inexact edges maximum tolerance', split_max_distnace_between_face_and_halfspace: float = 0.0001, split_unify_same_domains: bool = False, split_sew: bool = False, split_skip_non_cutting_planes: bool = True, split_skip_non_cutting_planes_rel_tol: float = 1e-07, _def_split_max_distnace_between_face_and_halfspace: str = 'max dist between face and halfspace used to recursively split', _def_split_unify_same_domains: str = 'apply unify same domains to merge periodic or duplicated conicident faces following splitting', _def_split_sew: str = 'split sew to solids following recursive splitting', _def_split_skip_non_cutting_planes: str = 'skip the half space and split of planar faces whose plane leaves the whole solid on the material side (they cannot split it)', _def_split_skip_non_cutting_planes_rel_tol: str = 'tolerance, relative to the solid size, for a solid to count as lying behind a planar face', bool_common_fuzzy_value: float = 1e-06, bool_cutter_fuzzy_value: float = 1e-06, bool_splitter_fuzzy_value: float = 1e-06, bool_degenerate_min_area_to_vol_ratio: float = 0.0001, bool_degenerate_min_vol_fraction_of_original: float = 1e-10, bool_degenerate_min_ab_vol: float = 1e-10, _def_bool_common_fuzzy_value: str = 'fuzzy logic value passed to common boolean operation', _def_bool_cutter_fuzzy_value: str = 'fuzzy logic value passed to the cut boolean operation', _def_bool_splitter_fuzzy_value: str = 'fuzzy logic value passed to the split boolean operation', _def_bool_degenerate_min_area_to_vol_ratio: str = 'area to vol ration limit, used to filter degenerate solids in boolean operations', _def_bool_degenerate_min_vol_fraction_of_original: str = 'minumum volume required as a fraction of the original solid', _def_bool_degenerate_min_ab_vol: str = 'minimum volume of any split solid produced via boolean operation', make_face_tol: float = 1e-06, _def_make_face_tol: str = 'tolerance used when making a face', surf_plane_tol_normal_angle: float = 1e-06, surf_plane_tol_on_axis: float = 1e-06, surf_plane_tol_distance: float = 1e-06, surf_plane_rounding_lateral: int = 5, surf_plane_rounding_vector: int = 8, surf_cylinder_tol_axis_angle: float = 1e-06, surf_cylinder_tol_radius: float = 1e-06, surf_cylinder_tol_axis_distance: float = 1e-06, surf_cylinder_rounding_lateral: int = 5, surf_cylinder_rounding_radius: int = 5, surf_sph_radius_tol: float = 1e-06, surf_sph_position_tol: float = 1e-06, surf_cone_semi_angle_tol: float = 1e-06, surf_cone_axis_angle_tol: float = 1e-06, surf_cone_axis_distance_tol: float = 1e-06, surf_cone_rounding_lateral: int = 5, surf_cone_rounding_t_sq: int = 8, surf_tol_tori_minor_radius: float = 1e-06, surf_tol_tori_major_radius: float = 1e-06, surf_tol_tori_axis_angle: float = 1e-06, surf_tol_tori_centre: float = 1e-06, surf_tori_rounding_lateral: int = 8, surf_tori_rounding_radii: int = 8, surf_general_quadratic_rounding_abc: int = 8, surf_general_quadratic_rounding_def: int = 8, surf_general_quadratic_rounding_ghj: int = 8, surf_general_quadratic_rounding_k: int = 8, _def_surf_plane_tol_normal_angle: str = 'coincident planes: normal angle tolerance (degrees)', _def_surf_plane_tol_on_axis: str = 'ocp to mcio plane: on axis tol angle (degrees)', _def_surf_plane_tol_distance: str = 'ocp to mcio plane: distance between planes with same normal', _def_surf_plane_rounding_lateral: str = 'ocp to mcio plane: decimal place rounding of lateral x, y, z and d parameters', _def_surf_plane_rounding_vector: str = 'ocp to mcio plane: decimal place rounding of vector a, b, c parameters', _def_surf_cylinder_tol_axis_angle: str = 'ocp to mcio cyl: on axis tol angle (degrees)', _def_surf_cylinder_tol_radius: str = 'coincident cyl: radius tolerance', _def_surf_cylinder_tol_axis_distance: str = 'coincident cyl: axis distance', _def_surf_cylinder_rounding_lateral: str = 'ocp to mcio cyl: decimal place rounding of lateral x, y, and z parameters', _def_surf_cylinder_rounding_radius: str = 'ocp to mcio cyl: decimal place rounding of radius parameter', _def_surf_sph_radius_tol: str = 'coincident sph: radius tolerance', _def_surf_sph_position_tol: str = 'coincident sph: distance of centres tolerance', _def_surf_cone_semi_angle_tol: str = 'coincident cone: semi angle tolerance (degrees)', _def_surf_cone_axis_angle_tol: str = 'ocp to mcio cone: on axis angle tolerance (degrees)', _def_surf_cone_axis_distance_tol: str = 'ocp to mcio cone: on axis tolerance', _def_surf_cone_rounding_lateral: str = 'ocp to mcio cone: rounding number of dp for apex cartesian x,y,z', _def_surf_cone_rounding_t_sq: str = 'ocp to mcio cone: rounding of t_sq number of dp, t_sq = tan(semi_angle)**2', _def_surf_tol_tori_minor_radius: str = 'coincident tori: minor radius tolerance', _def_surf_tol_tori_major_radius: str = 'coincident tori: major radius tolerance', _def_surf_tol_tori_axis_angle: str = 'ocp to mcio tori: on axis angle tolerance (degrees)', _def_surf_tol_tori_centre: str = 'coincident tori: distance of centres tolerance', _def_surf_tori_rounding_lateral: str = 'ocp to mcio tori: decimal place rounding of lateral x, y, and z parameters', _def_surf_tori_rounding_radii: str = 'ocp to mcio tori: decimal place rounding of major and minor radii parameters', _def_surf_general_quadratic_rounding_abc: str = 'decimal places to round GQ a, b and c params', _def_surf_general_quadratic_rounding_def: str = 'decimal places to round GQ d, e and f params', _def_surf_general_quadratic_rounding_ghj: str = 'decimal places to round GQ g, h and k params', _def_surf_general_quadratic_rounding_k: str = 'decimal places to round GQ a, b and c params', wire_is_closed_tol: float = 1e-06, _def_wire_is_closed_tol: str = 'tolerance checking if wire is closed', void_max_recursion_depth: int = 30, void_min_width: float = 10.0, void_max_split_solids_per_octant: int = 50, void_max_faces_per_octant: int = 250, void_use_split_solid_distance_check: bool = False, void_split_solid_fractoin_of_bounding_box: float = 0.5, void_split_solid_distance_tol: float = 0.01, void_filter_by_face: bool = False, void_face_distance_tol: float = 0.01, void_bounding_box_use_optimal: bool = False, void_use_obb_check: bool = True, void_use_halfspace_pruning: bool = True, _def_void_max_recursion_depth: str = 'maximum recursive depth', _def_void_min_width: str = 'minimum void width of octant', _def_void_max_split_solids_per_octant: str = 'maximum split solids in octant', _def_void_max_faces_per_octant: str = 'maximum split solid faces per octant (excludes auxiliaries)', _def_void_use_split_solid_distance_check: str = '', _def_void_split_solid_fractoin_of_bounding_box: str = 'maximum fraction of the bounding box a split solid can contain before distance checks carried out', _def_void_split_solid_distance_tol: str = '', _def_void_filter_by_face: str = '', _def_void_face_distance_tol: str = 'distance tolerance for BRepExtrema_DistanceShapeShapes between void bounding box and face', _def_void_bounding_box_use_optimal: str = 'during void generation use the AddOptimal method for tighter bounding boxes', _def_void_use_obb_check: str = 'filter split solids per octant by oriented bounding box (separating axis test) after the axis aligned check', _def_void_use_halfspace_pruning: str = 'classify split solid half spaces against each octant: drop solids proven outside, drop half spaces proven to contain the octant, skip octants inside a solid', bounding_box_multiplier_half_space: float = 10, _def_bounding_box_multiplier_half_space: str = 'expansion factor for bounding box rpp solid used for halfspace', aux_generate: bool = True, aux_bounding_box_analysis: float = 1.5, aux_surface_face_distace_tol: float = 0.0001, aux_surface_cylinder_angle_tol: float = 1e-06, aux_surface_cylinder_small_angle: float = 0.0017453292519943296, aux_surface_cylinder_simple: bool = True, aux_surface_cone_angle_tol: float = 1e-06, aux_surface_cone_small_angle: float = 0.0017453292519943296, aux_surface_cone_simple: bool = True, aux_surface_sphere_angle_tol: float = 1e-06, aux_surface_sphere_small_angle: float = 0.0017453292519943296, aux_surface_sphere_simple: bool = True, aux_surface_tori_angle_tol: float = 1e-06, aux_surface_tori_small_angle: float = 0.0017453292519943296, aux_surface_tori_aux_surface_simple: bool = True, _def_aux_generate: str = 'generate auxiliary surfaces for second order faces', _def_aux_bounding_box_analysis: str = 'extension of bounding box for aux surface in analysis save to cad', _def_aux_surface_face_distace_tol: str = 'distance tolerance for faces to be grouped fo coincident surfaces', _def_aux_surface_cylinder_angle_tol: str = 'aux surface cylinder angle tolerance (degrees)', _def_aux_surface_cylinder_small_angle: str = 'aux surface cylinder small angle tolerance (degrees)', _def_aux_surface_cylinder_simple: str = 'apply simple auxiliary surface method (true or false)', _def_aux_surface_cone_angle_tol: str = 'aux surface cone angle tolerance (degrees)', _def_aux_surface_cone_small_angle: str = 'aux surface cone small angle tolerance (degrees)', _def_aux_surface_cone_simple: str = 'apply simple auxiliary surface method (true or false)', _def_aux_surface_sphere_angle_tol: str = 'aux surface sphere angle tolerance (degrees)', _def_aux_surface_sphere_small_angle: str = 'aux surface sphere small angle tolerance (degrees)', _def_aux_surface_sphere_simple: str = 'apply simple auxiliary surface method (true or false)', _def_aux_surface_tori_angle_tol: str = 'auxiliary surface: tori angle tolerance (degrees)', _def_aux_surface_tori_small_angle: str = 'auxiliary surface: tori small angle tolerance (degrees)', _def_aux_surface_tori_aux_surface_simple: str = 'apply simple auxiliary surface method (true or false)', model_set_output_cell_vols: bool = True, model_implicit_void_for_no_mateirals: bool = True, _def_model_set_output_cell_vols: str = 'assign volume to output csg file', _def_model_implicit_void_for_no_mateirals: str = 'Where no material is assigned, cells set to void be default. Otherwise require material assignment', debug_cut_fatal_path: str = 'analysis/cut_fatal/cut_fatal.stp', debug_cut_warning_path: str = 'analysis/cut_warnings/cut_warning.stp', debug_cut_error_path: str = 'analysis/cur_errors/cut_error.stp', debug_common_fatal_path: str = 'analysis/common_fatal/common_fatal.stp', debug_common_warning_path: str = 'analysis/common_warnings/common_warning.stp', debug_common_error_path: str = 'analysis/common_errors/common_error.stp', debug_splitter_fatal_path: str = 'analysis/splitter_fatal/splitter_fatal.stp', debug_splitter_warning_path: str = 'analysis/splitter_warnings/splitter_warning.stp', debug_splitter_error_path: str = 'analysis/splitter_errors/splitter_error.stp', debug_filter_degenerate_solid_path: str = 'analysis/degenerate_solids/degenerate_solid.stp', debug_cut_common_path: str = 'analysis/cut_andcut_common/cut_common.stp', debug_volume_conserved_path: str = 'analysis/vol_not_conserved/vol_not_conserved.stp', debug_pipe_splitter: str = 'analysis/pre_pipe_splitter/pre_pipe_split.stp', debug_concentric_splitter: str = 'analysis/concentric_splitter/pre_concentric_split.stp', debug_rectilinear_splitter: str = 'analysis/rectilinear_splitter/pre_rectilinear_split.stp', debug_invalid_solid_path: str = 'analysis/invalid_solid/invalid_solid.stp', _def_debug_invalid_solid_path: str = 'debugging: path of solids failing the validity check after clean up', debug_half_space_failed_to_generate_path: str = 'analysis/half_space_fatal/half_space_fatal.stp', debug_failed_to_convert_directory: str = 'analysis/failed_to_convert', debug_save_solid: str = 'analysis/solids', debug_write_added_solids: bool = False, _def_debug_write_added_solids: str = 'debugging: write each solid added to the decomposer to a STEP file in added_solids/', debug_cad_output_verbosity: int = 1, debug_logger_verbosity: int = 1, debug_long_conversion_time: float = 20.0, debug_long_conversion_time_directory: str = 'analysis/long_conversion_time', debug_large_number_of_split_solids: int = 50, debug_large_number_of_split_solids_directory: str = 'analysis/large_number_of_split_solids', debug_trackback_directory: str = 'analysis/trackbacks', _def_debug_cut_fatal_path: str = 'debugging: path of failed cut operations, dumps solids to step file', _def_debug_cut_warning_path: str = 'debugging: path of cut operation with warning(s)', _def_debug_cut_error_path: str = 'debugging: path of cut with error(s)', _def_debug_common_fatal_path: str = 'debugging: path of failed common operations, dumps solids to step file', _def_debug_common_warning_path: str = 'debugging: path of common operation with warning(s)', _def_debug_common_error_path: str = 'debugging: path of common operation with error(s)', _def_debug_splitter_fatal_path: str = 'debugging: path of failed splitter operations, dumps solids to step file', _def_debug_splitter_warning_path: str = 'debugging: path of splitter operation with warning(s)', _def_debug_splitter_error_path: str = 'debugging: path of splitter operation with error(s)', _def_debug_filter_degenerate_solid_path: str = 'debugging: path of filtered degenerate solids', _def_debug_cut_common_path: str = 'debugging: path of cut and common operation where 2+ commons created', _def_debug_volume_conserved_path: str = 'debugging: path of failed conserved volume operations, dumps solids to step file', _def_debug_pipe_splitter: str = 'debugging: path of step output following successful split of pipe', _def_debug_concentric_splitter: str = 'debugging: path to step output following successful split of concentril second order surfaces', _def_debug_rectilinear_splitter: str = 'debugging: path to step output following successful rectilinear pre-split', _def_debug_half_space_failed_to_generate_path: str = 'debugging: path of failed to generate half space, dumps to step file', _def_debug_failed_to_convert_directory: str = 'debugging: each failed decomposition solid will be saved to this directory', _def_debug_save_solid: str = 'debugging: save the solid before attempting to convert', _def_debug_cad_output_verbosity: str = 'level of debugging output to step files, either 0 for nothing, 1 for printing and 2 for saving to step', _def_debug_logger_verbosity: str = 'level of debugging output to logger, either 0 for nothing, 1 for repoting issues or 2 for step by step reporting', _def_debug_long_conversion_time: str = 'debug: save output file to stp showing long conversion times above this value (seconds)', _def_debug_long_conversion_time_directory: str = 'debuig: output dir for solids with long conversion times', _def_debug_large_number_of_split_solids: str = 'debug: save output file to stp for solids with large numbers of split solids produced', _def_debug_large_number_of_split_solids_directory: str = 'debug: save dir for output of solids with large numbers of split solids', _def_debug_trackback_directory: str = 'debug: save trackback for multiprocessing to text files for each failed solid to this directory', other_nominal_gap: float = 0.0, _def_other_nominal_gap: str = '')

Bases: ParameterLookup

Data class used to store all constants used in decomposition.

Parameter names are lower case (PEP 8) and start with a category key word (e.g. surf, void) so that the parameters can be printed in separate tables. Each parameter also has a counterpart with _def_ prepended to its name, which is a string holding its definition.

Notes

Every class-level annotated attribute is a dataclass field and may be overridden via the constructor keyword of the same name. The former upper case names (e.g. VOID_MIN_WIDTH) are still accepted as attributes, with a DeprecationWarning.

Examples

>>> params = DecompositionParameters(void_min_width=20.0)
>>> params.void_use_obb_check = False
aux_bounding_box_analysis: float
aux_generate: bool
aux_surface_cone_angle_tol: float
aux_surface_cone_simple: bool
aux_surface_cone_small_angle: float
aux_surface_cylinder_angle_tol: float
aux_surface_cylinder_simple: bool
aux_surface_cylinder_small_angle: float
aux_surface_face_distace_tol: float
aux_surface_sphere_angle_tol: float
aux_surface_sphere_simple: bool
aux_surface_sphere_small_angle: float
aux_surface_tori_angle_tol: float
aux_surface_tori_aux_surface_simple: bool
aux_surface_tori_small_angle: float
bool_common_fuzzy_value: float
bool_cutter_fuzzy_value: float
bool_degenerate_min_ab_vol: float
bool_degenerate_min_area_to_vol_ratio: float
bool_degenerate_min_vol_fraction_of_original: float
bool_splitter_fuzzy_value: float
bounding_box_multiplier_half_space: float
cleanup_inexact_edge_fix_tol_max: float
cleanup_inexact_edge_fix_tol_min: float
cleanup_inexact_edges: bool
cleanup_inexact_edges_tol: float
cleanup_shape_fix: bool
cleanup_shape_fix_tol_max: float
cleanup_shape_fix_tol_min: float
cleanup_unify_same_domains: bool
debug_cad_output_verbosity: int
debug_common_error_path: str
debug_common_fatal_path: str
debug_common_warning_path: str
debug_concentric_splitter: str
debug_cut_common_path: str
debug_cut_error_path: str
debug_cut_fatal_path: str
debug_cut_warning_path: str
debug_failed_to_convert_directory: str
debug_filter_degenerate_solid_path: str
debug_half_space_failed_to_generate_path: str
debug_invalid_solid_path: str
debug_large_number_of_split_solids: int
debug_large_number_of_split_solids_directory: str
debug_logger_verbosity: int
debug_long_conversion_time: float
debug_long_conversion_time_directory: str
debug_pipe_splitter: str
debug_rectilinear_splitter: str
debug_save_solid: str
debug_splitter_error_path: str
debug_splitter_fatal_path: str
debug_splitter_warning_path: str
debug_trackback_directory: str
debug_volume_conserved_path: str
debug_write_added_solids: bool
doc_unit_in_metres: float
doc_xcaf_formatting: str
make_face_tol: float
model_implicit_void_for_no_mateirals: bool
model_set_output_cell_vols: bool
other_nominal_gap: float
presplit_about_axis: str
presplit_about_axis_n_times: int
presplit_concentril_2nd_order: bool
presplit_pipes: bool
presplit_pipes_cyl_angle_tol: float
presplit_rectilinear_voxels: bool
presplit_rectilinear_voxels_width: float
split_max_distnace_between_face_and_halfspace: float
split_sew: bool
split_skip_non_cutting_planes: bool
split_skip_non_cutting_planes_rel_tol: float
split_unify_same_domains: bool
surf_cone_axis_angle_tol: float
surf_cone_axis_distance_tol: float
surf_cone_rounding_lateral: int
surf_cone_rounding_t_sq: int
surf_cone_semi_angle_tol: float
surf_cylinder_rounding_lateral: int
surf_cylinder_rounding_radius: int
surf_cylinder_tol_axis_angle: float
surf_cylinder_tol_axis_distance: float
surf_cylinder_tol_radius: float
surf_general_quadratic_rounding_abc: int
surf_general_quadratic_rounding_def: int
surf_general_quadratic_rounding_ghj: int
surf_general_quadratic_rounding_k: int
surf_plane_rounding_lateral: int
surf_plane_rounding_vector: int
surf_plane_tol_distance: float
surf_plane_tol_normal_angle: float
surf_plane_tol_on_axis: float
surf_sph_position_tol: float
surf_sph_radius_tol: float
surf_tol_tori_axis_angle: float
surf_tol_tori_centre: float
surf_tol_tori_major_radius: float
surf_tol_tori_minor_radius: float
surf_tori_rounding_lateral: int
surf_tori_rounding_radii: int
void_bounding_box_use_optimal: bool
void_face_distance_tol: float
void_filter_by_face: bool
void_max_faces_per_octant: int
void_max_recursion_depth: int
void_max_split_solids_per_octant: int
void_min_width: float
void_split_solid_distance_tol: float
void_split_solid_fractoin_of_bounding_box: float
void_use_halfspace_pruning: bool
void_use_obb_check: bool
void_use_split_solid_distance_check: bool
wire_is_closed_tol: float