Region

Region Operators

Operation

Symbol (Python)

Symbol (MCNP)

Semantics

Union

|

:

OR

Intersection

&

space

AND

Complement

~

#

NOT

Note

Complements may be applied to cells or regions.

class mcnpy.Region(*args, **kwargs)

Bases: Region, ABC

A representation of the model object Region.

static from_expression(expression, surfaces, cells)

Generate a region given an infix expression.

Parameters
  • expression (str) – Boolean expression relating surface half-spaces. The possible operators are union ‘|’, intersection ‘ ‘, and complement ‘~’. For example, ‘(1 -2) | 3 ~(4 -5)’.

  • surfaces (dict) – Dictionary whose keys are suface IDs that appear in the Boolean expression and whose values are Surface objects.

get_surfaces(surfaces=None)

Recursively find all surfaces referenced by a region and return them

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)

Recursively remove all redundant surfaces referenced by this region

Parameters

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

class mcnpy.Intersection(*args, **kwargs)

Bases: Intersection, Region, MutableSequence

A representation of the model object Intersection.

Parameters

nodes (iterable of mcnpy.Region) – Nodes for Intersection.

insert(index, value)

S.insert(index, value) – insert value before index

class mcnpy.Union(*args, **kwargs)

Bases: Union, Region, MutableSequence

A representation of the model object Union.

Parameters

nodes (iterable of mcnpy.Region) – Nodes for Union.

insert(index, value)

S.insert(index, value) – insert value before index

class mcnpy.Complement(*args, **kwargs)

Bases: Complement, Region

A representation of the model object Complement.

Parameters
get_surfaces(surfaces=None)

Recursively find and return all the surfaces referenced by the node

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)

Recursively remove all redundant surfaces referenced by this region

New in version 0.12.

Parameters

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