PENGEOM¶
Base classes¶
Definition of base PENGEOM classes.
-
class
pypenelopetools.pengeom.base.
GeometryBase
[source]¶ Bases:
object
Base class for geometry objects.
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 48¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_create_expline
(keyword, value, termination='')[source]¶ Creates a exponent line. This type of line is characterised by a keyword, a value express as an exponent (see
_toexponent()
) and a termination string. The keyword and the total length of the line is checked not to exceed their respective maximum size.Parameters:
-
_create_line
(keyword, text, termination='')[source]¶ Creates an input line from the specified keyword, text and comment. The white space between the items is automatically adjusted to fit the line size. The keyword and the total length of the line is checked not to exceed their respective maximum size.
Parameters:
-
_peek_next_line
(fileobj)[source]¶ Returns the next line without advancing the current position.
Parameters: fileobj (file object) – File object opened with read access. Returns: Next line, stripped of all trailing white spaces. Return type: str
-
_read
(fileobj, material_lookup, surface_lookup, module_lookup)[source]¶ Reads file object.
Parameters: - fileobj (file object) – File object opened with read access.
- material_lookup (dict(int,
Material
)) – A lookup table for the materials used in the geometry. Dictionary where the keys are material indexes in the geometry file and the values,Material
instances. - surface_lookup (dict(int,
Surface
)) – A lookup table for surfaces used in the geometry. Dictionary where the keys are surface indexes in the geometry file and the values,Surface
instances. - module_lookup (dict(int,
Module
)) – A lookup table for modules used in the geometry. Dictionary where the keys are module indexes in the geometry file and the values,Module
instances.
-
_read_next_line
(fileobj)[source]¶ Returns the next line and advances the current position.
Parameters: fileobj (file object) – File object opened with read access. Returns: Next line, stripped of all trailing white spaces. Return type: str
-
_write
(fileobj, index_lookup)[source]¶ Writes to file object.
Parameters: - fileobj (file object) – File object opened with write access.
- index_lookup (dict(
GeometryBase
, int)) – A lookup table for the surfaces, modules and materials of the associated geometry. Each component is assigned an index by the methodindexify
. Dictionary where the keys are surfaces, modules and materials instances, and the values, an integer index.
-
-
pypenelopetools.pengeom.base.
_toexponent
(number)[source]¶ Formats exponent to PENELOPE format (E22.15)
Parameters: number (Float) – Number to format Returns: number to PENELOPE format (E22.15) Return type: str
Mixins used to create geometry objects.
-
class
pypenelopetools.pengeom.mixin.
DescriptionMixin
[source]¶ Bases:
object
Mixin that adds a description property.
-
description
¶ str – Description of the geometry object.
-
-
class
pypenelopetools.pengeom.mixin.
ModuleMixin
[source]¶ Bases:
object
Mixin that adds methods to add, pop and clear modules.
Definition of geometrical transformations.
-
class
pypenelopetools.pengeom.transformation.
Rotation
(omega_deg=0.0, theta_deg=0.0, phi_deg=0.0)[source]¶ Bases:
pypenelopetools.pengeom.base.GeometryBase
Represents a rotation using 3 Euler angles (YZY).
Parameters: -
omega_deg
¶ float – Rotation around the z-axis (deg). The value must be between 0 and 360.
-
phi_deg
¶ float – 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.
-
theta_deg
¶ float – Rotation around the y-axis (deg). The value must be between 0 and 360.
-
-
class
pypenelopetools.pengeom.transformation.
Scale
(x=1.0, y=1.0, z=1.0)[source]¶ Bases:
pypenelopetools.pengeom.base.GeometryBase
Represents scaling.
Parameters: -
x
¶ float – Scaling along the x direction. The value cannot be 0.
-
y
¶ float – Scaling along the y direction. The value cannot be 0.
-
z
¶ float – Scaling along the z direction. The value cannot be 0.
-
-
class
pypenelopetools.pengeom.transformation.
Shift
(x_cm=0.0, y_cm=0.0, z_cm=0.0)[source]¶ Bases:
pypenelopetools.pengeom.base.GeometryBase
Represents a translation in space.
Parameters: -
x_cm
¶ float – Translation along the x direction (cm).
-
y_cm
¶ float – Translation along the y direction (cm).
-
z_cm
¶ float – Translation along the z direction (cm).
-
Geometry¶
Geometry definition for PENGEOM.
-
class
pypenelopetools.pengeom.geometry.
Geometry
(title='Untitled', tilt_deg=0.0, rotation_deg=0.0)[source]¶ Bases:
pypenelopetools.pengeom.mixin.ModuleMixin
,pypenelopetools.pengeom.base.GeometryBase
Creates a new PENELOPE geometry.
Parameters: -
clear_modules
()¶ Clear all modules.
-
indexify
()[source]¶ Returns a lookup table which associates the surfaces, modules and materials of this geometry to their index used in the geometry file. The lookup table is a dictionary where the keys are surfaces, modules and materials instances, and the values, an integer index.
-
rotation_deg
¶ Specimen rotation in degrees along the z-axis
-
tilt_deg
¶ Specimen tilt in degrees along the x-axis
-
title
¶ Title of the geometry. The title must have less than 61 characters.
-
write
(fileobj, index_lookup=None)[source]¶ Writes the geometry file (
.geo
) to create this geometry.Parameters: - fileobj (file object) – File object opened with write access.
- index_lookup (dict(
GeometryBase
, int), optional) – A lookup table for the surfaces, modules and materials of this geometry. IfNone
, the index lookup is generated by the methodindexify
.
Returns: lookup table
Return type: dict(
GeometryBase
, int)
-
Surfaces¶
Definition of surfaces.
-
class
pypenelopetools.pengeom.surface.
SurfaceImplicit
(coefficients=None, description='')[source]¶ Bases:
pypenelopetools.pengeom.surface.SurfaceBase
Definition of an implicit surface.
Parameters: - coefficients (dict(str, float) or list(float)) – Coefficients for the implicit form of the quadratic equation.
If the argument is a
dict
, the keys are the names of coefficient (e.g.xx
) and the values the coefficient values. If the argument is alist
, the list must contain 10 values, one for each coefficient. - description (str) – Description of the surface
-
coefficients
¶ (dict(str, float) or list(float)) – Coefficients for the implicit form of the quadratic equation. If the value is a
dict
, the keys are the names of coefficient (e.g.xx
) and the values the coefficient values. If the argument is alist
, the list must contain 10 values, one for each coefficient.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 = {'xx': 1.0, 'xy': 1.0}
-
description
¶ str – Description of the geometry object.
- coefficients (dict(str, float) or list(float)) – Coefficients for the implicit form of the quadratic equation.
If the argument is a
-
class
pypenelopetools.pengeom.surface.
SurfaceReduced
(indices=None, description='')[source]¶ Bases:
pypenelopetools.pengeom.surface.SurfaceBase
Definition of a reduced/explicit surface.
Parameters: -
description
¶ str – Description of the geometry object.
-
indices
¶ (tuple(int)) – Indices for the explicit form of the quadratic equation. Indices are 5 integers (-1, 0 or 1) defining the surface.
-
-
pypenelopetools.pengeom.surface.
xplane
(x_cm)[source]¶ Returns a surface for a plane X=x.
Parameters: x_cm (float) – Intercept on the x-axis (in cm). Returns: SurfaceReduced
-
pypenelopetools.pengeom.surface.
yplane
(y_cm)[source]¶ Returns a surface for a plane Y=y.
Parameters: y_cm (float) – Intercept on the y-axis (in cm). Returns: SurfaceReduced
-
pypenelopetools.pengeom.surface.
zplane
(z_cm)[source]¶ Returns a surface for a plane Z=z.
Parameters: z_cm (float) – Intercept on the z-axis (in cm). Returns: SurfaceReduced
-
pypenelopetools.pengeom.surface.
cylinder
(radius_cm, axis='x')[source]¶ Returns a surface for a cylinder along axis with radius.
Parameters: Returns:
-
pypenelopetools.pengeom.surface.
sphere
(radius_cm)[source]¶ Returns a surface for a sphere or radius.
Parameters: radius_cm (float) – Radius of the sphere (in cm). Returns: SurfaceReduced
Module¶
Definition of module.
-
class
pypenelopetools.pengeom.module.
Module
(material=None, description='')[source]¶ Bases:
pypenelopetools.pengeom.mixin.DescriptionMixin
,pypenelopetools.pengeom.mixin.ModuleMixin
,pypenelopetools.pengeom.base.GeometryBase
Definition of a module.
Parameters: -
add_surface
(surface, pointer)[source]¶ Adds a surface.
Parameters: - surface (
SurfaceImplicit
orSurfaceReduced
) – Surface to add. - pointer (
SidePointer
) – Whether the surface is pointing in the positive or negative direction.
- surface (
-
get_surface_pointer
(surface)[source]¶ Returns the surface pointer for the specified surface.
Parameters: surface ( SurfaceImplicit
orSurfaceReduced
) – Surface of interest.Returns: Side pointer. Return type: SidePointer
-
pop_surface
(surface)[source]¶ Removes a surface.
Parameters: surface ( SurfaceImplicit
orSurfaceReduced
) – Surface to remove.
-
-
class
pypenelopetools.pengeom.module.
SidePointer
[source]¶ Bases:
enum.IntEnum
Whether the surface is pointing in the positive or negative direction.
-
NEGATIVE
= -1¶ Negative direction.
-
POSITIVE
= 1¶ Positive direction.
-