pyPENELOPE

geometry – Geometry definition for PENGEOM

Inheritance diagram of penelopetools.api.input.pengeom.geometry

class penelopetools.api.input.pengeom.geometry.Clone(module_index=1, description='', rotation=None, shift=None)

Bases: object

Creates a new Clone. A clone is copy of a module. The clone can be rotated and shifted with respect to its original module.

Parameters:
  • module_index (int) – id of the module to clone
  • description (str) – description of the module (default='')
  • rotation (Rotation) – rotation of the clone
  • shift (Shift) – shift of the clone
ATTR_DESCRIPTION = 'description'
ATTR_MODULE_INDEX = 'moduleIndex'
KEYWORD_MODULE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990e50>
TAG_NAME = 'clone'
description

Description of the clone.

classmethod from_xml(element)

Creates a Clone from a XML element.

Parameters:element – XML element
module_index

Index of the module from which the clone is created. The index must be greater or equal to 1.

rotation

Rotation of the clone. The rotation is defined by a Rotation. If the attribute is deleted, no rotation is performed.

shift

Shift/translation of the clone. The shift is defined by a Shift. If the attribute is deleted, no shift is performed.

to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

class penelopetools.api.input.pengeom.geometry.Geometry(title='Untitled', filename='untitled.geo', surfaces=None, modules=None)

Bases: penelopetools.api.input.penelope.option.Option

Creates a new Geometry. The geometry stores all options to create a geometry file (.GEO) readable by PENEGEOM as well as the input line for the IN file.

Parameters:
  • title – title of the geometry
  • filename – filename of the GEO file
  • surfaces (Surfaces) – surfaces defining the geometry
  • modules (Modules) – modules defining the geometry
ATTR_CLASS = 'class'
ATTR_FILENAME = 'filename'
ATTR_TITLE = 'title'
KEYWORD = <penelopetools.api.input.penelope.util.Keyword object at 0x70bf090>
TAG_NAME = 'geometry'
filename

Filename of the geometry.

classmethod from_inputfile(lines)

Creates a Geometry from lines of a IN file.

Parameters:lines – lines
classmethod from_xml(root)

Creates a Geometry from a XML element.

Parameters:element – XML element
title

Title of the geometry. The title must have less than 61 charaters.

to_geofile()

Returns the lines of this option to create a GEO file.

to_html(header_level=1)

Returns a HTML representation of this option.

to_inputfile()

Returns the lines of this option to create a IN file.

to_xml()

Returns a XML representation of this option.

class penelopetools.api.input.pengeom.geometry.Module(material_id=0, surface_pointers=[], module_indexes=[], description='', rotation=None, shift=None)

Bases: object

Creates a new Module. A module is a regroupment of surfaces and modules creating a region in space with the same material.

Parameters:
  • material_id (int) – index of the module’s material (default=0)
  • surface_pointers (list) – list of SurfacePointer forming the boundaries of the module. (default=[])
  • module_indexes (list) – list of indexes forming the boundaries of the module. (default=[])
  • description (str) – description of the module (default='')
  • rotation (Rotation) – rotation of the module
  • shift (Shift) – shift of the module
ATTR_DESCRIPTION = 'description'
ATTR_MATERIAL_ID = 'materialId'
KEYWORD_MATERIAL = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990d10>
KEYWORD_MODULE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990d90>
KEYWORD_SURFACE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990d50>
TAG_MODULE_INDEX = 'moduleIndex'
TAG_NAME = 'module'
description

Description of the module.

classmethod from_xml(element)

Creates a Module from a XML element.

Parameters:element – XML element
material_id

Id of the material associated with the module. The id must be greater or equal to zero.

module_indexes

List of indexes forming the boundaries of the module. If the attribute is deleted, the list of module indexes is emptied.

rotation

Rotation of the surface. The rotation is defined by a Rotation. If the attribute is deleted, no rotation is performed.

shift

Shift/translation of the surface. The shift is defined by a Shift. If the attribute is deleted, no shift is performed.

surface_pointers

List of SurfacePointer forming the boundaries of the module. If the attribute is deleted, the list of surface pointers is emptied.

to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

validate()

Validates the module. Checks that a surface has only one surface pointer and that a module is only present once in the module indexes.

class penelopetools.api.input.pengeom.geometry.Modules(data={})

Bases: dict

Store the modules/clones of a geometry. Clones are considered as modules

A unique index is created for every module. The first index is equal to 1. The index corresponds to the identifier of modules in PENGEOM.

ATTR_INDEX = 'index'
KEYWORD_CLONE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990f50>
KEYWORD_MODULE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990f10>
TAG_NAME = 'modules'
add(module, index=None)

Adds a new module or clone. If index is not given, a new index is generated automatically. If a index of an existing module/clone is given, the later is overwritten.

Returns:return the index of the newly created module
Return type:int
clones

Return the dictionary containing only Clone

Return type:dict
classmethod from_xml(element)

Creates a Modules from a XML element.

Parameters:element – XML element
modules

Returns the dictionary containing only Module

Return type:dict
setdefault(k)
to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

update(E, **F)
class penelopetools.api.input.pengeom.geometry.Rotation(omega=0.0, theta=0.0, phi=0.0)

Bases: object

Creates a new Rotation. This class is used to specify the rotation of Surface and Module.

Parameters:
  • omega – rotation around the z-axis (deg)
  • theta – rotation around the y-axis (deg)
  • phi – rotation around the new z-axis (deg)
ATTR_OMEGA = 'omega_deg'
ATTR_PHI = 'phi_deg'
ATTR_THETA = 'theta_deg'
KEYWORD_OMEGA = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990310>
KEYWORD_PHI = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990390>
KEYWORD_THETA = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990350>
TAG_NAME = 'rotation'
classmethod from_xml(element)

Creates a Rotation from a XML element.

Parameters:element – XML element
omega

Rotation around the z-axis (deg). The value must be between 0 and 360 deg. The value is stored in a magnitude.Magnitude.

phi

Rotation around the new z-axis (deg). The new z-axis refer to the axis after the omega and theta rotation were applied on the original coordinate system. The value must be between 0 and 360 deg. The value is stored in a magnitude.Magnitude.

theta
to_geofile()

Returns the lines of this class to create a GEO file.

to_html(header_level=1)

Returns a HTML representation of this option.

to_xml()

Returns a XML representation of this class.

class penelopetools.api.input.pengeom.geometry.Scale(x=1.0, y=1.0, z=1.0)

Bases: object

Creates a new Scale. This class is used to specify the scaling of a Surface.

Parameters:
  • x – scaling along the x direction (cm)
  • y – scaling along the y direction (cm)
  • z – scaling along the z direction (cm)
ATTR_X = 'x'
ATTR_Y = 'y'
ATTR_Z = 'z'
KEYWORD_X = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990610>
KEYWORD_Y = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990650>
KEYWORD_Z = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990690>
TAG_NAME = 'scale'
classmethod from_xml(element)

Creates a Scale from a XML element.

Parameters:element – XML element
to_geofile()

Returns the lines of this class to create a GEO file.

to_html(header_level=1)

Returns a HTML representation of this option.

to_xml()

Returns a XML representation of this class.

x

Scaling along the x direction (cm). The value cannot be 0. The value is stored in a magnitude.Magnitude.

y

Scaling along the y direction (cm). The value cannot be 0. The value is stored in a magnitude.Magnitude.

z

Scaling along the z direction (cm). The value cannot be 0. The value is stored in a magnitude.Magnitude.

class penelopetools.api.input.pengeom.geometry.Shift(x=0.0, y=0.0, z=0.0)

Bases: object

Creates a new Shift. This class is used to specify the translation in space of Surface and Module.

Parameters:
  • x – translation along the x direction (cm)
  • y – translation along the y direction (cm)
  • z – translation along the z direction (cm)
ATTR_X = 'x_cm'
ATTR_Y = 'y_cm'
ATTR_Z = 'z_cm'
KEYWORD_X = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990490>
KEYWORD_Y = <penelopetools.api.input.pengeom.util.Keyword object at 0x69904d0>
KEYWORD_Z = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990510>
TAG_NAME = 'shift'
classmethod from_xml(element)

Creates a Shift from a XML element.

Parameters:element – XML element
to_geofile()

Returns the lines of this class to create a GEO file.

to_html(header_level=1)

Returns a HTML representation of this option.

to_xml()

Returns a XML representation of this class.

x

Translation along the x direction (cm). The value is stored in a magnitude.Magnitude.

y

Translation along the y direction (cm). The value is stored in a magnitude.Magnitude.

z

Translation along the z direction (cm). The value is stored in a magnitude.Magnitude.

class penelopetools.api.input.pengeom.geometry.Surface(indices=(0, 0, 0, 0, 0), description='', scale=None, rotation=None, shift=None, coefficients={'xz': 0.0, 'yy': 0.0, 'xx': 0.0, 'xy': 0.0, '0': 0.0, 'zz': 0.0, 'yz': 0.0, 'y': 0.0, 'x': 0.0, 'z': 0.0})

Bases: object

Creates a new Surface.

Parameters:
  • indices (tuple) – indices representing the implicit form of the quadratic equation
  • description (str) – description of the surface (default='')
  • scale (Scale) – scale factor of the surface
  • rotation (Rotation) – rotation of the surface
  • shift (Shift) – shift of the surface
  • coefficients (dict or list or tuple) – coefficients of the quadratic equation. There are only used if indices=(0,0,0,0,0)
ATTRS_INDICES = 'abcde'
ATTR_DESCRIPTION = 'description'
KEYWORD_A0 = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990a50>
KEYWORD_AX = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990990>
KEYWORD_AXX = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990810>
KEYWORD_AXY = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990850>
KEYWORD_AXZ = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990890>
KEYWORD_AY = <penelopetools.api.input.pengeom.util.Keyword object at 0x69909d0>
KEYWORD_AYY = <penelopetools.api.input.pengeom.util.Keyword object at 0x69908d0>
KEYWORD_AYZ = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990910>
KEYWORD_AZ = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990a10>
KEYWORD_AZZ = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990950>
KEYWORD_INDICES = <penelopetools.api.input.pengeom.util.Keyword object at 0x69907d0>
TAG_COEFFICIENTS = 'coefficients'
TAG_INDICES = 'indices'
TAG_NAME = 'surface'
coefficients

Coefficients for the implicit form of the quadratic equation. The coefficients will only be used if the indices are all equal to zero. The coefficients are defined by a dictionary, a list or a tuple. See examples below. If the attribute is deleted, the coefficients are all set to zero.

Examples:

>>> s = Surface()
>>> s.coefficients = {'xx': 0.0, 'xy': 0.0, 'xz': 0.0, 'yy': 0.0, 'yz': 0.0, 'zz': 0.0, 'x': 0.0, 'y': 0.0, 'z': 0.0, '0': 0.0}
>>> s.coefficients = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
>>> s.coefficients = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
>>> s.coefficients = {'xx': 1.0, 'xy': 1.0}
description

Description of the surface.

classmethod from_xml(element)

Creates a Surface from a XML element.

Parameters:element – XML element
indices

Indices for the explicit form of the quadratic equation. The indices are defined by a tuple containing 5 indices (-1, 0 or 1). If the attribute is deleted, all the indices are set to 0.

is_implicit_form()

Return whether the implicit form of the quadratic equation is used. The implicit form implies that all the indices are equal to 0.

rotation

Rotation of the surface. The rotation is defined by a Rotation. If the attribute is deleted, no rotation is performed.

scale

Scaling of the surface. The scaling is defined by a Scale. If the attribute is deleted, no scaling is performed.

shift

Shift/translation of the surface. The shift is defined by a Shift. If the attribute is deleted, no shift is performed.

to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

class penelopetools.api.input.pengeom.geometry.SurfacePointer(surface_index=1, sidepointer=1)

Bases: object

Creates a new SurfacePointer to be used in Module

Parameters:
  • surface_index (int) – index of the surface
  • sidepointer (int) – Side pointer indicates if the positive or negative side of the surface is taken to create the module. (either SIDEPOINTER_POSITIVE or SIDEPOINTER_NEGATIVE)
ATTR_SIDEPOINTER = 'sidepointer'
ATTR_SURFACE_INDEX = 'surfaceIndex'
KEYWORD_SIDEPOINTER = ', SIDE POINTER='
KEYWORD_SURFACE = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990c50>
TAG_NAME = 'surfacePointer'
classmethod from_xml(element)

Creates a SurfacePointer from a XML element.

Parameters:element – XML element
sidepointer

Side pointer indicates if the positive or negative side of the surface is taken to create the module. The value can either be SIDEPOINTER_POSITIVE or SIDEPOINTER_NEGATIVE.

surface_index

Index of the surface. The index must be greater or equal to zero.

to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

class penelopetools.api.input.pengeom.geometry.Surfaces(data={})

Bases: dict

Stores the surfaces of a geometry.

A unique index is created for every surface. The index corresponds to the identifier of surfaces in PENGEOM.

ATTR_INDEX = 'index'
KEYWORD = <penelopetools.api.input.pengeom.util.Keyword object at 0x6990b10>
TAG_NAME = 'surfaces'
add(surface, index=None)

Adds a new Surface to the list. If index is not given, a new index is generated automatically. If a index of an existing surface is given, the later is overwritten.

Returns:return the index of the newly created surface
Return type:int
classmethod from_xml(element)

Creates a Surfaces from a XML element.

Parameters:element – XML element
setdefault(k)

Not implemted.

to_geofile()

Returns the lines of this class to create a GEO file.

to_xml()

Returns a XML representation of this class.

update(E, **F)

Not implemted.

penelopetools.api.input.pengeom.geometry.cylinder(radius, axis='z')

Returns a surface for a cylinder along axis with radius

Parameters:
  • radius – radius of the cylinder (in cm)
  • axis – axis of the cylinder (AXIS_X, AXIS_Y or AXIS_Z)
Return type:

Surface

penelopetools.api.input.pengeom.geometry.is_registered(geometry_class)
penelopetools.api.input.pengeom.geometry.register(geometry_class)
penelopetools.api.input.pengeom.geometry.sphere(radius)

Returns a surface for a sphere or radius

Parameters:radius – radius of the cylinder (in cm)
Return type:Surface
penelopetools.api.input.pengeom.geometry.xplane(x)

Returns a surface for a plane X=x

Parameters:z – intercept on the x-axis (in cm)
Return type:Surface
penelopetools.api.input.pengeom.geometry.yplane(y)

Returns a surface for a plane Y=y

Parameters:z – intercept on the y-axis (in cm)
Return type:Surface
penelopetools.api.input.pengeom.geometry.zplane(z)

Returns a surface for a plane Z=z

Parameters:z – intercept on the z-axis (in cm)
Return type:Surface