t4_geom_convert.Kernel.Surface package

Submodules

t4_geom_convert.Kernel.Surface.CTransformationMCNP module

class t4_geom_convert.Kernel.Surface.CTransformationMCNP.CTransformationMCNP(l_originTransformation, l_rotationTransformation)

Bases: object

Class which permit to access precisely to the information of the transformation part of the block DATA.

t4_geom_convert.Kernel.Surface.CollectionDict module

Module containing the definition of the CollectionDict class.

class t4_geom_convert.Kernel.Surface.CollectionDict.CollectionDict

Bases: MutableMapping

This class represents a dictionary mapping MCNP surfaces to lists of objects.

For example, here we fill a dictionary with a couple of surfaces:

>>> from MIP.geom.semantics import Surface
>>> from t4_geom_convert.Kernel.Surface.SurfaceMCNP import SurfaceMCNP
>>> import t4_geom_convert.Kernel.Surface.ESurfaceTypeMCNP as EMS
>>> MS = EMS.ESurfaceTypeMCNP
>>> planex = SurfaceMCNP('', MS.P, [1.0, 0.0, 0.0, 0.0], [])
>>> planey = SurfaceMCNP('', MS.P, [0.0, 1.0, 0.0, 0.0], [])
>>> planez = SurfaceMCNP('', MS.P, [0.0, 0.0, 1.0, 0.0], [])
>>> dic = CollectionDict()
>>> dic[1] = [(planex, 1)]
>>> dic[Surface(2)] = [(planey, -1), (planez, 1)]

In this example, surface 1 divides space in two regions (x>0 and x<0), with the convention that x>0 lies on the positive side of the surface.

Surface 2 consists of two sub-surfaces (the y=0 plane and the z=0 plane). This again divides space in two regions: the first one, which by convention is the outer side of surface 2, lies on the negative side of planey and on the positive side of planez (i.e. it is the y<0, z>0 quadrant); the other region is the complement of this quadrant, that is the union of y>0 and z<0.

You can query objects from the dictionary as usual:

>>> dic[Surface(2)]
[(SurfaceMCNP('', <ESurfaceTypeMCNP.P: 4>, (0.0, 1.0, 0.0, 0.0), (), ()), -1), (SurfaceMCNP('', <ESurfaceTypeMCNP.P: 4>, (0.0, 0.0, 1.0, 0.0), (), ()), 1)]

As you probably noticed above, you can also use integers in your queries:

>>> dic[2] == dic[Surface(2)]
True

Finally, you can also query subsurfaces. Note that the numbering of the subsurfaces starts at 1 (MCNP convention):

>>> dic[Surface(2, sub=1)]
[(SurfaceMCNP('', <ESurfaceTypeMCNP.P: 4>, (0.0, 1.0, 0.0, 0.0), (), ()), -1)]
>>> dic[Surface(2, sub=2)]
[(SurfaceMCNP('', <ESurfaceTypeMCNP.P: 4>, (0.0, 0.0, 1.0, 0.0), (), ()), 1)]

Out-of-range subsurface indices are not allowed:

>>> dic[Surface(2, sub=-1)]
Traceback (most recent call last):
    ...
IndexError: out of range subsurface (allowed range: [1, 2])

You can also use two integers to query subsurfaces:

>>> dic[2, 2] == dic[Surface(2, sub=2)]
True

You can modify subsurfaces, but you must always provide a list as a value: >>> dic[2, 2] = [(planex, -1)] >>> dic[2] [(SurfaceMCNP(‘’, <ESurfaceTypeMCNP.P: 4>, (0.0, 1.0, 0.0, 0.0), (), ()), -1), (SurfaceMCNP(‘’, <ESurfaceTypeMCNP.P: 4>, (1.0, 0.0, 0.0, 0.0), (), ()), -1)]

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
number_items()

Return a numbering of the items in the collection, as well as a matching between the keys in this dictionary and the keys in the numbering.

values() an object providing a view on D's values

t4_geom_convert.Kernel.Surface.ConstructSurfaceT4 module

t4_geom_convert.Kernel.Surface.ConstructSurfaceT4.construct_surface_t4(mcnp_parser)

Method constructing a dictionary with the id of the surface as a key and the instance of SurfaceT4 as a value.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4 module

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.conversion_surface_params(key, val)

Convert the MCNP surface described by val into a TRIPOLI-4 surface.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_cone(key, val)

Convert the parameters for cones.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_cylinder(val)

Convert the parameters for cylinders.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_mcnp_surface(key, val)

Perform the actual conversion of an MCNP surface.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_mcnp_surfaces(dic_surface_mcnp)

Method which convert MCNP surface and constructing the dictionary of Surface T4.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_plane(val)

Convert the parameters for planes.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_quadric(val)

Convert the parameters for a quadric.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_special_quadric(val)

Convert the parameters for a quadric in SQ form.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_sphere(val)

Convert the parameters for spheres.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.convert_torus(val)

Convert the parameters for tori.

t4_geom_convert.Kernel.Surface.ConversionSurfaceMCNPToT4.eval_quadric(params, point)

Evaluate the quadric represented by params at point.

>>> quad = [1.0, 1.0, 1.0,  # this is a sphere of radius 1.0
...         0.0, 0.0, 0.0,
...         0.0, 0.0, 0.0, -1.0]
>>> eval_quadric(quad, (0.0, 0.0, 0.0)) < 0.0
True
>>> eval_quadric(quad, (0.999, 0.0, 0.0)) < 0.0
True
>>> eval_quadric(quad, (1.001, 0.0, 0.0)) > 0.0
True
>>> eval_quadric(quad, (2.000, 0.0, 0.0)) > 0.0
True

t4_geom_convert.Kernel.Surface.DTypeConversion module

Module specifying each conversion of surface type.

t4_geom_convert.Kernel.Surface.Duplicates module

This module contains utilities to simplify surface dictionaries.

t4_geom_convert.Kernel.Surface.Duplicates.remove_duplicate_surfaces(surfs)

This function that detects duplicate surfaces from a surface dictionary, removes them and provides a dictionary where the IDs of the deleted surfaces are associated with the ID of the surface that replaced them.

t4_geom_convert.Kernel.Surface.Duplicates.renumber_surfaces(volus, renumbering)

Apply the given surface renumbering to the volume definitions.

t4_geom_convert.Kernel.Surface.ESurfaceTypeMCNP module

class t4_geom_convert.Kernel.Surface.ESurfaceTypeMCNP.ESurfaceTypeMCNP(value)

Bases: Enum

An enumeration.

ARB = 43
BOX = 33
C = 16
CX = 13
CY = 14
CZ = 15
C_X = 10
C_Y = 11
C_Z = 12
ELL = 41
GQ = 25
HEX = 37
K = 23
KX = 20
KY = 21
KZ = 22
K_X = 17
K_Y = 18
K_Z = 19
P = 4
PX = 1
PY = 2
PZ = 3
RCC = 36
REC = 39
RHP = 38
RPP = 34
S = 6
SO = 5
SPH = 35
SQ = 24
SX = 7
SY = 8
SZ = 9
T = 26
TRC = 40
TX = 27
TY = 28
TZ = 29
WED = 42
X = 30
Y = 31
Z = 32
t4_geom_convert.Kernel.Surface.ESurfaceTypeMCNP.mcnp_to_mip(en)
t4_geom_convert.Kernel.Surface.ESurfaceTypeMCNP.string_to_enum(type_surface)

t4_geom_convert.Kernel.Surface.ESurfaceTypeT4 module

class t4_geom_convert.Kernel.Surface.ESurfaceTypeT4.ESurfaceTypeT4(value)

Bases: Enum

An enumeration.

CONE = 13
CONEX = 10
CONEY = 11
CONEZ = 12
CYL = 9
CYLX = 6
CYLY = 7
CYLZ = 8
PLANE = 4
PLANEX = 1
PLANEY = 2
PLANEZ = 3
QUAD = 14
SPHERE = 5
TORUSX = 15
TORUSY = 16
TORUSZ = 17

t4_geom_convert.Kernel.Surface.MacroBodies module

exception t4_geom_convert.Kernel.Surface.MacroBodies.MacroBodyError(type_, expected, params)

Bases: Exception

Error that is raised if the number of macrobody parameters differs from the expected number.

t4_geom_convert.Kernel.Surface.MacroBodies.arb(params)

Transform the parameters of a ARB macrobody.

Parameters:

params (list) – the thirty (!) MCNP parameters for ARB

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.box(params)

Transform the parameters of a BOX macrobody.

This function is actually capable of handling generic parallelepipeds (MCNP mandates that the parallelepiped must be right).

Parameters:

params (list) – the twelve MCNP parameters for BOX

Returns:

a list of triples representing the surfaces that collectively describe the macrobody. The first element of each triple is the type of the surface; the second element is a list of coefficients; the third element is an integer (=±1) indicating on which side of the plane the macrobody lies; if the integer is +1, the outside of the macrobody lies in the “positive” direction for the surface.

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.check_params_length(type_, expected, params)

Throw a MacroBodyError if the number of parameters present does not match the expected number.

t4_geom_convert.Kernel.Surface.MacroBodies.ell(params)

Transform the parameters of an ELL macrobody.

An ELL is not a generic ellipsoid, but a spheroid. It can be oblate or prolate depending on the parameters.

MCNP provides two possible ways to enter the parameters, depending on the sign of the last one. The documentation in the MCNP manual is terse and does not correspond to what the code does. For instance, the surfaces

ELL 0 0 -2 0 0 2 6 ELL 0 0 0 0 0 3 -2

are claimed to be equivalent, but they are not. I am not sure if the bug is in the code, the documentation or both. Anyway, the converter treats ELL like MCNP does.

Parameters:

params (list) – the seven MCNP parameters for ELL

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.parse_facet(facet_int)

Convert an integer representing a facet into a tuple of its elements.

Polyhedron facets in the MCNP input are represented as integers. Each digit represents the index of a vertex. For instance, the integer 1256 represents the facet bounded by vertices 1, 2, 5 and 6.

This function converts the integer representation into a tuple of indices, which is more convenient to work with. For example:

>>> parse_facet(1256)
(0, 1, 4, 5)

Note that the resulting indices are zero-based, which is more suitable for Python.

Zeros are ignored:

>>> parse_facet(5230)
(4, 1, 2)
>>> parse_facet(7024)
(6, 1, 3)
Parameters:

facet_int (int) – the integer representing the facets

Returns:

a tuple of indices

Return type:

tuple(int)

t4_geom_convert.Kernel.Surface.MacroBodies.rcc(params)

Transform the parameters of an RCC macrobody.

Parameters:

params (list) – the seven MCNP parameters for RCC

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.rec(params)

Transform the parameters of an REC macrobody.

Parameters:

params (list) – the ten/twelve MCNP parameters for REC

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.rhp(params)

Transform the parameters of an RHP/HEX macrobody.

Parameters:

params (list) – the fifteen MCNP parameters for RHP

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.rpp(params)

Transform the parameters of an RPP macrobody.

Parameters:

params (list) – the six MCNP parameters for RPP

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.sph(params)

Transform the parameters of an SPH macrobody.

Parameters:

params (list) – the four MCNP parameters for SPH

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.trc(params)

Transform the parameters of a TRC macrobody.

Parameters:

params (list) – the fifteen MCNP parameters for TRC

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.MacroBodies.wed(params)

Transform the parameters of a WED macrobody.

Parameters:

params (list) – the twelve MCNP parameters for WED

Returns:

see box()

Return type:

list((ESurfaceTypeMCNP, list(float), int))

t4_geom_convert.Kernel.Surface.SurfaceCollection module

Module containing the SurfaceCollection class.

class t4_geom_convert.Kernel.Surface.SurfaceCollection.SurfaceCollection(surfs)

Bases: Sequence

A class that represents a single surface as a collection of surfaces.

This class is necessary to represent, for instance, MCNP’s macrobodies or one-nappe cones.

classmethod join(surf_colls)

Create a SurfaceCollection from a list of pairs of SurfaceCollection objects and integers.

t4_geom_convert.Kernel.Surface.SurfaceConversionError module

Module containing the SurfaceConversionError class.

exception t4_geom_convert.Kernel.Surface.SurfaceConversionError.SurfaceConversionError

Bases: Exception

An error in surface conversion.

t4_geom_convert.Kernel.Surface.SurfaceMCNP module

class t4_geom_convert.Kernel.Surface.SurfaceMCNP.SurfaceMCNP(boundary_cond, type_surface, param_surface, compl_param, idorigin=None)

Bases: object

Class that contains the information of the MCNP surface cards.

t4_geom_convert.Kernel.Surface.SurfaceT4 module

class t4_geom_convert.Kernel.Surface.SurfaceT4.SurfaceT4(type_surface, param_surface, idorigin=None, transform=None)

Bases: object

Class that contains the information of the TRIPOLI-4 SURF keyword.

comment()

Return the comment string for this surface, if any.

transform_block()

Return a string representing a coordinate transformation to be applied to the T4 surface, or None if no transformation is required.

Module contents