montepy.surface_collection module

class montepy.surface_collection.Surfaces(surfaces=None, problem=None)

Bases: NumberedObjectCollection

A collection of multiple montepy.surfaces.surface.Surface instances.

This collection has a generator for every supported type of MCNP surface. These are accessed by the for lower case version of the MCNP mnemonic. For example you can access all planes normal to the z-axis through .pz

This example will shift all PZ surfaces up by 10 cm.

for surface in problem.surfaces.pz:
    surface.location += 10
Parameters:

surfaces (list) – the list of surfaces to start with if needed

append(obj)

Appends the given object to the end of this collection.

Parameters:

obj (Numbered_MCNP_Object) – the object to add.

Raises:

NumberConflictError – if this object has a number that is already in use.

append_renumber(obj, step=1)

Appends the object, but will renumber the object if collision occurs.

This behaves like append, except if there is a number collision the object will be renumbered to an available number. The number will be incremented by step until an available number is found.

Parameters:
  • obj (Numbered_MCNP_Object) – The MCNP object being added to the collection.

  • step (int) – the incrementing step to use to find a new number.

Returns:

the number for the object.

Return type:

int

property arb

Generator for getting all surfaces of type arbitrary polyhedron or ARB

property box

Generator for getting all surfaces of type orthogonal box or BOX

property c_x

Generator for getting all surfaces of type cylinder parallel to x-axis or C/X

property c_y

Generator for getting all surfaces of type cylinder parallel to y-axis or C/Y

property c_z

Generator for getting all surfaces of type cylinder parallel to z-axis or C/Z

check_number(number)

Checks if the number is already in use, and if so raises an error.

Parameters:

number (int) – The number to check.

Raises:

NumberConflictError – if this number is in use.

clear()

Removes all objects from this collection.

property cx

Generator for getting all surfaces of type cylinder on x-axis or CX

property cy

Generator for getting all surfaces of type cylinder on y-axis or CY

property cz

Generator for getting all surfaces of type cylinder on z-axis or CZ

property ell

Generator for getting all surfaces of type ellipsoid or ELL

extend(other_list)

Extends this collection with another list.

Parameters:

other_list (list) – the list of objects to add.

Raises:

NumberConflictError – if these items conflict with existing elements.

get(i: int, default=None) -> (<class 'montepy.numbered_mcnp_object.Numbered_MCNP_Object'>, None)

Get i if possible, or else return default.

Parameters:
  • i (int) – number of the object to get, not it’s location in the internal list

  • default (object) – value to return if not found

Return type:

Numbered_MCNP_Object

property gq

Generator for getting all surfaces of type cylinder, cone, ellipsoid hyperboloid, or parabaloid not parallel to an axis or GQ

property hex

Generator for getting all surfaces of type right hexagonal prism or HEX

items() Generator[Tuple[int, Numbered_MCNP_Object], None, None]

Get iterator of the collections (number, object) pairs.

Return type:

tuple(int, MCNP_Object)

property k_x

Generator for getting all surfaces of type cone parallel to x-axis or K/X

property k_y

Generator for getting all surfaces of type cone parallel to y-axis or K/Y

property k_z

Generator for getting all surfaces of type cone parallel to z-axis or K/Z

keys() Generator[int, None, None]

Get iterator of the collection’s numbers.

Return type:

int

property kx

Generator for getting all surfaces of type cone on x-axis or KX

property ky

Generator for getting all surfaces of type cone on y-axis or KY

property kz

Generator for getting all surfaces of type cone on z-axis or KZ

Links the card to the parent problem for this card.

This is done so that cards can find links to other objects.

Parameters:

problem (MCNP_Problem) – The problem to link this card to.

next_number(step=1)

Get the next available number, based on the maximum number.

This works by finding the current maximum number, and then adding the stepsize to it.

Parameters:

step (int) – how much to increase the last number by

property numbers

A generator of the numbers being used.

Return type:

generator

property objects

Returns a shallow copy of the internal objects list.

The list object is a new instance, but the underlying objects are the same.

Return type:

list

property p

Generator for getting all surfaces of type general plane or P

pop(pos=-1)

Pop the final items off of the collection

Parameters:

pos (int) – The index of the element to pop from the internal list.

Returns:

the final elements

Return type:

Numbered_MCNP_Object

property px

Generator for getting all surfaces of type plane normal to x-axis or PX

property py

Generator for getting all surfaces of type plane normal to y-axis or PY

property pz

Generator for getting all surfaces of type plane normal to z-axis or PZ

property rcc

Generator for getting all surfaces of type right circular cylinder or RCC

property rec

Generator for getting all surfaces of type right elliptical cylinder or REC

remove(delete)

Removes the given object from the collection.

Parameters:

delete (Numbered_MCNP_Object) – the object to delete

request_number(start_num=1, step=1)

Requests a new available number.

This method does not “reserve” this number. Objects should be immediately added to avoid possible collisions caused by shifting numbers of other objects in the collection.

Parameters:
  • start_num (int) – the starting number to check.

  • step (int) – the increment to jump by to find new numbers.

Returns:

an available number

Return type:

int

property rhp

Generator for getting all surfaces of type right hexagonal prism or RHP

property rpp

Generator for getting all surfaces of type rectangular parallelepiped or RPP

property s

Generator for getting all surfaces of type general sphere or S

property so

Generator for getting all surfaces of type sphere centered at origin or SO

property sph

Generator for getting all surfaces of type sphere or SPH

property sq

Generator for getting all surfaces of type ellipsoid, hyperboloid, or paraboloid parallel to an axis or SQ

property sx

Generator for getting all surfaces of type sphere centered on x-axis or SX

property sy

Generator for getting all surfaces of type sphere centered on y-axis or SY

property sz

Generator for getting all surfaces of type sphere centered on z-axis or SZ

property trc

Generator for getting all surfaces of type truncated right-angle cone or TRC

property tx

Generator for getting all surfaces of type elliptical torus parallel to x-axis or TX

property ty

Generator for getting all surfaces of type elliptical torus parallel to y-axis or TY

property tz

Generator for getting all surfaces of type elliptical torus parallel to z-axis or TZ

values() Generator[Numbered_MCNP_Object, None, None]

Get iterator of the collection’s objects.

Return type:

Numbered_MCNP_Object

property wed

Generator for getting all surfaces of type wedge or WED

property x

Generator for getting all surfaces of type axisymmetric surface defined by points or X

property y

Generator for getting all surfaces of type axisymmetric surface defined by points or Y

property z

Generator for getting all surfaces of type axisymmetric surface defined by points or Z