Surfaces

class mcnpy.Surface(*args, **kwargs)[source]

Bases: Surface

A representation of the model object Surface.

Parameters
  • name (int) – Numeric ID for Surface.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Surface.

get_coefficients()[source]
next_id = 1
print_surface()[source]
used_ids = {}
class mcnpy.Halfspace(*args, **kwargs)[source]

Bases: Halfspace

A representation of the model object Halfspace.

Parameters
  • side (mcnpy.PositiveNegative) – Side for Halfspace.

  • pseudo_cell (int) – PseudoCell for Halfspace.

  • surface (mcnpy.Surface) – Surface for Halfspace.

  • facets (str) – Facets for Halfspace.

get_surfaces(surfaces=None)[source]

Returns the surface that this is a halfspace of.

Parameters

surfaces (collections.OrderedDict, optional) – Dictionary mapping surface IDs to mcnpy.Surface instances

Returns

surfaces – Dictionary mapping surface IDs to mcnpy.Surface instances

Return type

collections.OrderedDict

remove_redundant_surfaces(redundant_surfaces)[source]

Recursively remove all redundant surfaces referenced by this region

Parameters

redundant_surfaces (dict) – Dictionary mapping redundant surface IDs to surface IDs for the mcnpy.Surface instances that should replace them.

Halfspace Operators

Operation

Symbol (Python)

Symbol (MCNP)

Positive

+

+ OR space

Negative

-

-

class mcnpy.SurfaceFacet(surface, facet)[source]

Bases: object

property facet
get_coefficients()[source]
print_surface()[source]
class mcnpy.Macrobody[source]

Bases: ABC

All macrobodies with facets. Excludes Sphere and Ellipsoid.

facets(facet: int)[source]

Note

Facets can be specified using [] on an applicable surface.

# A macrobody with facets.
rpp = mcnpy.RectangularPrism(name=10, ...)
# Define halfspace using facet 6.
hs = +rpp[6]

Sphere

class mcnpy.Sphere(*args, **kwargs)[source]

Bases: IDManagerMixin, Sphere, Surface

Sphere defined by \color{eqn}(x-x_{0})^{2} + (y-y_{0})^{2} + (z-z_{0})^{2} - r^{2} = 0.

Parameters
  • name (int) – Numeric ID for Sphere.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Sphere.

  • x0 (float) – X0 for Sphere.

  • y0 (float) – Y0 for Sphere.

  • z0 (float) – Z0 for Sphere.

  • r (float) – R for Sphere.

  • comment (str) – Comment for Sphere.

get_coefficients()[source]

Plane

class mcnpy.XPlane(*args, **kwargs)[source]

Bases: IDManagerMixin, XPlane, Surface

A plane defined by \color{eqn}x - x_{0} = 0.

Parameters
  • name (int) – Numeric ID for XPlane.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XPlane.

  • x0 (float) – X0 for XPlane.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.YPlane(*args, **kwargs)[source]

Bases: IDManagerMixin, YPlane, Surface

A plane defined by \color{eqn}y - y_{0} = 0.

Parameters
  • name (int) – Numeric ID for YPlane.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for YPlane.

  • y0 (float) – Y0 for YPlane.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.ZPlane(*args, **kwargs)[source]

Bases: IDManagerMixin, ZPlane, Surface

A plane defined by \color{eqn}z - z_{0} = 0.

Parameters
  • name (int) – Numeric ID for ZPlane.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for ZPlane.

  • z0 (float) – Z0 for ZPlane.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.Plane(*args, **kwargs)[source]

Bases: IDManagerMixin, Plane, Surface

A plane defined by \color{eqn}Ax + By + Cz - D = 0.

Parameters
  • name (int) – Numeric ID for Plane.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Plane.

  • a (float) – A for Plane.

  • b (float) – B for Plane.

  • c (float) – C for Plane.

  • d (float) – D for Plane.

  • comment (str) – Comment for Plane.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]

Cylinder

class mcnpy.XCylinder(*args, **kwargs)[source]

Bases: IDManagerMixin, XCylinder, Surface

A cylinder parallel to the x-axis defined by \color{eqn}(y - y_{0})^{2} + (z - z_{0})^{2} - r^{2} = 0.

Parameters
  • name (int) – Numeric ID for XCylinder.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XCylinder.

  • y0 (float) – Y0 for XCylinder.

  • z0 (float) – Z0 for XCylinder.

  • r (float) – R for XCylinder.

  • comment (str) – Comment for XCylinder.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.YCylinder(*args, **kwargs)[source]

Bases: IDManagerMixin, YCylinder, Surface

A cylinder parallel to the y-axis defined by \color{eqn}(x - x_{0})^{2} + (z - z_{0})^{2} - r^{2} = 0.

Parameters
  • name (int) – Numeric ID for YCylinder.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for YCylinder.

  • x0 (float) – X0 for YCylinder.

  • z0 (float) – Z0 for YCylinder.

  • r (float) – R for YCylinder.

  • comment (str) – Comment for YCylinder.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.ZCylinder(*args, **kwargs)[source]

Bases: IDManagerMixin, ZCylinder, Surface

A cylinder parallel to the z-axis defined by \color{eqn}(x - x_{0})^{2} + (y - y_{0})^{2} - r^{2} = 0.

Parameters
  • name (int) – Numeric ID for ZCylinder.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for ZCylinder.

  • x0 (float) – X0 for ZCylinder.

  • y0 (float) – Y0 for ZCylinder.

  • r (float) – R for ZCylinder.

  • comment (str) – Comment for ZCylinder.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]

Cone

class mcnpy.XCone(*args, **kwargs)[source]

Bases: IDManagerMixin, XCone, Surface

A cone parallel to the x-axis defined by \color{eqn}\sqrt{(y - y_{0})^{2} + (z - z_{0})^{2}} - r(x - x_{0}) = 0. sheet can be +/-1.

Parameters
  • name (int) – Numeric ID for XCone.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XCone.

  • x0 (float) – X0 for XCone.

  • y0 (float) – Y0 for XCone.

  • z0 (float) – Z0 for XCone.

  • r2 (float) – R2 for XCone.

  • sheet (mcnpy.Sheet) – Sheet for XCone.

  • comment (str) – Comment for XCone.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.YCone(*args, **kwargs)[source]

Bases: IDManagerMixin, YCone, Surface

A cone parallel to the y-axis defined by \color{eqn}\sqrt{(x - x_{0})^{2} + (z - z_{0})^{2}} - r(y - y_{0}) = 0. sheet can be +/-1.

Parameters
  • name (int) – Numeric ID for YCone.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for YCone.

  • x0 (float) – X0 for YCone.

  • y0 (float) – Y0 for YCone.

  • z0 (float) – Z0 for YCone.

  • r2 (float) – R2 for YCone.

  • sheet (mcnpy.Sheet) – Sheet for YCone.

  • comment (str) – Comment for YCone.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.ZCone(*args, **kwargs)[source]

Bases: IDManagerMixin, ZCone, Surface

A cone parallel to the z-axis defined by \color{eqn}\sqrt{(x - x_{0})^{2} + (y - y_{0})^{2}} - r(z - z_{0}) = 0. sheet can be +/-1.

Parameters
  • name (int) – Numeric ID for ZCone.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for ZCone.

  • x0 (float) – X0 for ZCone.

  • y0 (float) – Y0 for ZCone.

  • z0 (float) – Z0 for ZCone.

  • r2 (float) – R2 for ZCone.

  • sheet (mcnpy.Sheet) – Sheet for ZCone.

  • comment (str) – Comment for ZCone.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.Sheet(*args, **kwargs)[source]

Bases: Sheet

A representation of the model object Sheet.

Parameters

Quadric

class mcnpy.Quadric(*args, **kwargs)[source]

Bases: IDManagerMixin, Quadric, Surface

Quadric (GQ) with axes not parallel to x-, y-, or z-axis. Defined by \color{eqn}Ax^{2} + By^{2} + Cz^{2} + Dxy + Eyz + Fzx + Gx + Hy + Jz + K = 0.

Parameters
  • name (int) – Numeric ID for Quadric.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Quadric.

  • a (float) – A for Quadric.

  • b (float) – B for Quadric.

  • c (float) – C for Quadric.

  • d (float) – D for Quadric.

  • e (float) – E for Quadric.

  • f (float) – F for Quadric.

  • g (float) – G for Quadric.

  • h (float) – H for Quadric.

  • j (float) – J for Quadric.

  • k (float) – K for Quadric.

  • comment (str) – Comment for Quadric.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]
class mcnpy.XYZQuadric(*args, **kwargs)[source]

Bases: IDManagerMixin, XYZQuadric, Surface

Quadric (SQ) with axes parallel to x-, y-, or z-axis. Defined by \color{eqn}A(x-x_{0})^{2} + B(y-y_{0})^{2} + C(z-z_{0})^{2} + 2D(x-x{0}) + 2E(y-y_{0}) + 2F(z-z_{0}) + G = 0.

Parameters
  • name (int) – Numeric ID for XYZQuadric.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XYZQuadric.

  • a (float) – A for XYZQuadric.

  • b (float) – B for XYZQuadric.

  • c (float) – C for XYZQuadric.

  • d (float) – D for XYZQuadric.

  • e (float) – E for XYZQuadric.

  • f (float) – F for XYZQuadric.

  • g (float) – G for XYZQuadric.

  • x (float) – X for XYZQuadric.

  • y (float) – Y for XYZQuadric.

  • z (float) – Z for XYZQuadric.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]

Torus

class mcnpy.XTorus(*args, **kwargs)[source]

Bases: IDManagerMixin, XTorus, Surface

Torus parallel to x-axis defined by \color{eqn}(x-x_{0})^{2}/B^{2} + \left(\sqrt{(y-y_{0})^{2} + (z-z_{0})^{2}} - A\right)^{2} / C^{2} - 1 = 0.

Parameters
  • name (int) – Numeric ID for XTorus.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XTorus.

  • x0 (float) – X0 for XTorus.

  • y0 (float) – Y0 for XTorus.

  • z0 (float) – Z0 for XTorus.

  • a (float) – A for XTorus.

  • b (float) – B for XTorus.

  • c (float) – C for XTorus.

  • comment (str) – Comment for XTorus.

get_coefficients()[source]
class mcnpy.YTorus(*args, **kwargs)[source]

Bases: IDManagerMixin, YTorus, Surface

Torus parallel to y-axis defined by \color{eqn}(y-y_{0})^{2}/B^{2} + \left(\sqrt{(x-x_{0})^{2} + (z-z_{0})^{2}} - A\right)^{2} / C^{2} - 1 = 0.

Parameters
  • name (int) – Numeric ID for YTorus.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for YTorus.

  • x0 (float) – X0 for YTorus.

  • y0 (float) – Y0 for YTorus.

  • z0 (float) – Z0 for YTorus.

  • a (float) – A for YTorus.

  • b (float) – B for YTorus.

  • c (float) – C for YTorus.

  • comment (str) – Comment for YTorus.

get_coefficients()[source]
class mcnpy.ZTorus(*args, **kwargs)[source]

Bases: IDManagerMixin, ZTorus, Surface

Torus parallel to z-axis defined by \color{eqn}(z-z_{0})^{2}/B^{2} + \left(\sqrt{(x-x_{0})^{2} + (y-y_{0})^{2}} - A\right)^{2} / C^{2} - 1 = 0.

Parameters
  • name (int) – Numeric ID for ZTorus.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for ZTorus.

  • x0 (float) – X0 for ZTorus.

  • y0 (float) – Y0 for ZTorus.

  • z0 (float) – Z0 for ZTorus.

  • a (float) – A for ZTorus.

  • b (float) – B for ZTorus.

  • c (float) – C for ZTorus.

  • comment (str) – Comment for ZTorus.

get_coefficients()[source]

Points

class mcnpy.XPoints(*args, **kwargs)[source]

Bases: IDManagerMixin, XPoints, Surface

X symmetric surface defined by points A representation of the model object XPoints.

Parameters
  • name (int) – Numeric ID for XPoints.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for XPoints.

  • points (iterable of mcnpy.PPoint) – Points for XPoints.

convert()[source]
get_coefficients()[source]
property points
class mcnpy.YPoints(*args, **kwargs)[source]

Bases: IDManagerMixin, YPoints, Surface

Y symmetric surface defined by points A representation of the model object YPoints.

Parameters
  • name (int) – Numeric ID for YPoints.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for YPoints.

  • points (iterable of mcnpy.PPoint) – Points for YPoints.

  • comment (str) – Comment for YPoints.

convert()[source]
get_coefficients()[source]
property points
class mcnpy.ZPoints(*args, **kwargs)[source]

Bases: IDManagerMixin, ZPoints, Surface

Z symmetric surface defined by points A representation of the model object ZPoints.

Parameters
  • name (int) – Numeric ID for ZPoints.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for ZPoints.

  • points (iterable of mcnpy.PPoint) – Points for ZPoints.

  • comment (str) – Comment for ZPoints.

convert()[source]
get_coefficients()[source]
property points
class mcnpy.PPoints(*args, **kwargs)[source]

Bases: IDManagerMixin, PPoints, Surface

Plane defined by 3 points A representation of the model object PPoints.

Parameters
  • name (int) – Numeric ID for PPoints.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for PPoints.

  • points (iterable of mcnpy.Point) – Points for PPoints.

  • comment (str) – Comment for PPoints.

get_base_coefficients()[source]

Returns coefficients for general quadric (GQ). Used for transformations.

get_coefficients()[source]

Macrobodies

class mcnpy.Box(*args, **kwargs)[source]

Bases: IDManagerMixin, Box, Surface, Macrobody

A Box defined by a corner and 2 or 3 vectors. A representation of the model object Box.

Parameters
  • name (int) – Numeric ID for Box.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Box.

  • corner (mcnpy.Point) – Corner for Box.

  • vectors (iterable of mcnpy.Point) – Vectors for Box.

  • comment (str) – Comment for Box.

get_coefficients()[source]
class mcnpy.CircularCylinder(*args, **kwargs)[source]

Bases: IDManagerMixin, CircularCylinder, Surface, Macrobody

A right circular cylinder defined by the center of its base, an axis vector, and radius r. A representation of the model object CircularCylinder.

Parameters
  • name (int) – Numeric ID for CircularCylinder.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for CircularCylinder.

  • base (mcnpy.Point) – Base for CircularCylinder.

  • axis (mcnpy.Point) – Axis for CircularCylinder.

  • r (float) – R for CircularCylinder.

  • comment (str) – Comment for CircularCylinder.

get_coefficients()[source]
class mcnpy.Ellipsoid(*args, **kwargs)[source]

Bases: IDManagerMixin, Ellipsoid, Surface, Macrobody

An Ellipsoid defined by a 2 points/vectors and a radius. By default, rm is the major radius and v1 and v2 are the coordinates of the first and second focii. If rm < 0 (meaning rm is now the minor radius), then v1 is the coordinates of the ellipsoid’s center and v2 is its major axis vector. A representation of the model object Ellipsoid.

Parameters
  • name (int) – Numeric ID for Ellipsoid.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Ellipsoid.

  • v1 (mcnpy.Point) – V1 for Ellipsoid.

  • v2 (mcnpy.Point) – V2 for Ellipsoid.

  • rm (float) – Rm for Ellipsoid.

  • comment (str) – Comment for Ellipsoid.

get_coefficients()[source]
class mcnpy.EllipticalCylinder(*args, **kwargs)[source]

Bases: IDManagerMixin, EllipticalCylinder, Surface, Macrobody

Right Elliptical Cylinder defined by a base point, axis height vector, ellipse major axis vector v1, and ellipse minor axis vector v1 or radius r. A representation of the model object EllipticalCylinder.

Parameters
  • name (int) – Numeric ID for EllipticalCylinder.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for EllipticalCylinder.

  • base (mcnpy.Point) – Base for EllipticalCylinder.

  • axis (mcnpy.Point) – Axis for EllipticalCylinder.

  • v1 (mcnpy.Point) – V1 for EllipticalCylinder.

  • v2 (mcnpy.Point) – V2 for EllipticalCylinder.

  • rm (float) – Rm for EllipticalCylinder.

  • comment (str) – Comment for EllipticalCylinder.

get_coefficients()[source]
class mcnpy.HexagonalPrism(*args, **kwargs)[source]

Bases: IDManagerMixin, HexagonalPrism, Surface, Macrobody

Right Hexagonal Prism defined by a base point, height vector, and facet vectors facet1, facet2, and facet3. The second and third facet vectors are optional. A representation of the model object HexagonalPrism.

Parameters
  • name (int) – Numeric ID for HexagonalPrism.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for HexagonalPrism.

  • base (mcnpy.Point) – Base for HexagonalPrism.

  • height (mcnpy.Point) – Height for HexagonalPrism.

  • facet1 (mcnpy.Point) – Facet1 for HexagonalPrism.

  • facet2 (mcnpy.Point) – Facet2 for HexagonalPrism.

  • facet3 (mcnpy.Point) – Facet3 for HexagonalPrism.

  • comment (str) – Comment for HexagonalPrism.

get_coefficients()[source]
class mcnpy.Polyhedron(*args, **kwargs)[source]

Bases: IDManagerMixin, Polyhedron, Surface, Macrobody

An Arbitrary Polyhedron (the ARB marcrobody). The shape of an ARB is specified by defining a list of the shape’s corners, corners, and a list of connectivity, sides, between those corners. corners are defined using mcnpy.Point objects while sides requires a list of integers. Each entry in sides is a 4 digit integer specifying the indicies defining a side. For instance, 1247 would indicate that a side is defined by the first, second, fourth, and seventh corner points. Note, these values are indexed from 1. For sides requiring only 3 corners, the three values are acceptable or a zero may be used instead. Valid ARBs may have 4, 5, or 6 sides using up to 8 corners. For example, a rectangular prism can be constructed with 8 corners and 6 sides. A tetrahedron would insted have 4 corners and 4 sides. For a more detailed description of ARB, users are advised to refer to the MCNP6.2 manual. A representation of the model object Polyhedron.

Parameters
  • name (int) – Numeric ID for Polyhedron.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Polyhedron.

  • corners (iterable of mcnpy.Point) – Corners for Polyhedron.

  • sides (iterable of int) – Sides for Polyhedron.

  • comment (str) – Comment for Polyhedron.

get_coefficients()[source]
validate()[source]

Checks that the corners and sides for a valid ARB.

class mcnpy.RectangularPrism(*args, **kwargs)[source]

Bases: IDManagerMixin, RectangularPrism, Surface, Macrobody

A rectangular parallelpiped defined by X, Y, and Z limits. Can be infinite in 1 dimension if upper and lower bounds are equal. A representation of the model object RectangularPrism.

Parameters
  • name (int) – Numeric ID for RectangularPrism.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for RectangularPrism.

  • x0 (float) – X0 for RectangularPrism.

  • x1 (float) – X1 for RectangularPrism.

  • y0 (float) – Y0 for RectangularPrism.

  • y1 (float) – Y1 for RectangularPrism.

  • z0 (float) – Z0 for RectangularPrism.

  • z1 (float) – Z1 for RectangularPrism.

  • comment (str) – Comment for RectangularPrism.

get_coefficients()[source]
class mcnpy.Wedge(*args, **kwargs)[source]

Bases: IDManagerMixin, Wedge, Surface, Macrobody

A Wedge defined by a vertex, 2 vectors for sides of the triangular base, and an axis height vector. A representation of the model object Wedge.

Parameters
  • name (int) – Numeric ID for Wedge.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for Wedge.

  • vertex (mcnpy.Point) – Vertex for Wedge.

  • vectors (iterable of mcnpy.Point) – Vectors for Wedge.

  • axis (mcnpy.Point) – Axis for Wedge.

  • comment (str) – Comment for Wedge.

get_coefficients()[source]
class mcnpy.TruncatedCone(*args, **kwargs)[source]

Bases: IDManagerMixin, TruncatedCone, Surface, Macrobody

Truncated Right Angle Cone defined by a base point, axis height vector, radius of the lower cone r0, and radius of the upper cone r1. A representation of the model object TruncatedCone.

Parameters
  • name (int) – Numeric ID for TruncatedCone.

  • boundary_type (mcnpy.BoundaryType) – Boundary condition for TruncatedCone.

  • base (mcnpy.Point) – Base for TruncatedCone.

  • axis (mcnpy.Point) – Axis for TruncatedCone.

  • r0 (float) – R0 for TruncatedCone.

  • r1 (float) – R1 for TruncatedCone.

  • comment (str) – Comment for TruncatedCone.

get_coefficients()[source]