pyg4ometry.fluka

Subpackages

Submodules

Classes

RPP

Rectangular Parallelepiped

BOX

General Rectangular Parallelepiped

SPH

Sphere

RCC

Right Circular Cylinder

REC

Right Elliptical Cylinder

TRC

Truncated Right-angled Cone

ELL

Ellipsoid of Revolution

WED

Right Angle Wedge

RAW

Base class representing a body as defined in FLUKA

ARB

Arbitrary Convex Polyhedron

XYP

Infinite half-space delimited by the x-y plane (perpendicular to the z-axis)

XZP

Infinite half-space delimited by the x-y plane (perpendicular to the y-axis)

YZP

Infinite half-space delimited by the x-y plane (perpendicular to the x-axis)

PLA

Infinite half-space delimited by the x-y plane (perpendicular to the z-axis) Generic infinite half-space.

XCC

Infinite Circular Cylinder parallel to the x-axis

YCC

Infinite Circular Cylinder parallel to the y-axis

ZCC

Infinite Circular Cylinder parallel to the z-axis

XEC

Infinite Elliptical Cylinder parallel to the x-axis

YEC

Infinite Elliptical Cylinder parallel to the y-axis

ZEC

Infinite Elliptical Cylinder parallel to the z-axis

QUA

Generic quadric

Reader

Class to read a FLUKA file.

Writer

Class to write FLUKA input files from a fluka registry object.

FlukaRegistry

Object to store geometry for FLUKA input and output. All of the FLUKA classes can be used without storing them in the Registry. The registry is used to write the FLUKA output file.

FlukaBodyStoreExact

Three

AABB

Zone

Represents a zone which consists of one or more body intersections

Region

Represents a region which consists of a region name, one or more

Transform

expansion, translation, rotoTranslation can be either a single

RotoTranslation

translation in mm, angles in degrees

RecursiveRotoTranslation

container for dealing with a recursively defined

Lattice

Flair

BuiltIn

Material

A FLUKA material consisting of a single element. This corresponds

Compound

A FLUKA compound material. This corresponds to the case in

Card

Card class for representing a FLUKA input card. To construct

Extruder

Base class for all solids

Functions

infinity(inf)

Use this to temporarily modify INFINITY, with it resetting back

bracket_depth(zone)

bracket_number(zone)

zone_to_sympy(zone)

region_to_sympy(region)

sympy_to_region(sympy_expr, freg[, regionName])

Convert sympy boolean to fluka region

Package Contents

class pyg4ometry.fluka.RPP(name, xmin, xmax, ymin, ymax, zmin, zmax, transform=None, flukaregistry=None, addRegistry=True, comment='')

Bases: BodyMixin

Rectangular Parallelepiped

Parameters:
  • name (str) – of body

  • xmin (float) – lower x coordinate of RPP

  • xmax (float) – upper x coordinate of RPP

  • ymin (float) – lower y coordinate of RPP

  • ymax (float) – upper y coordinate of RPP

  • zmin (float) – lower z coordinate of RPP

  • zmax (float) – upper z coordinate of RPP)

name
lower
upper
transform
comment
centre(aabb=None)
rotation()
lengths()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.BOX(name, vertex, edge1, edge2, edge3, transform=None, flukaregistry=None, addRegistry=True, comment='')

Bases: BodyMixin

General Rectangular Parallelepiped

Parameters:
  • name (str) – of body

  • vertex (list) – position [x, y, z] of one of the corners.

  • edge1 (list) – vector [x, y, z] denoting the first side of the box.

  • edge2 (list) – vector [x, y, z] denoting the second side of the box.

  • edge3 (list) – vector [x, y, z] denoting the second side of the box.

name
vertex
edge1
edge2
edge3
transform
comment
centre(aabb=None)
rotation()
lengths()
geant4Solid(greg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.SPH(name, point, radius, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Sphere

Parameters:
  • name (str) – of body

  • point (list) – position [x, y, z] of the centre of the sphere.

  • radius (float) – radius of the sphere.

name
point
radius
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.RCC(name, face, direction, radius, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Right Circular Cylinder

Parameters:
  • name (str) – of body

  • vertex (list) – position [x, y, z] of one of the faces of the cylinder.

  • edge1 (list) – vector [x, y, z] denoting the direction along the length of the cylinder.

  • edge2 (float) – radius of the cylinder face.

name
face
direction
radius
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.REC(name, face, direction, semiminor, semimajor, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Right Elliptical Cylinder

Parameters:
  • name (str) – of body

  • vertex (list) – position [x, y, z] of one of the faces of the cylinder.

  • semiminor (list) – vector [x, y, z] denoting the direction along the semiminor axis of the ellipse.

  • semimajor (list) – vector [x, y, z] denoting the direction along the semimajor axis of the ellipse.

name
face
direction
semiminor
semimajor
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.TRC(name, major_centre, direction, major_radius, minor_radius, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Truncated Right-angled Cone

Parameters:
  • name (str) – of body

  • major_centre (list) – vector [x, y, z] position of the centre of the larger face.

  • direction (list) – vector [x, y, z] pointing from the larger face to the smaller face.

  • major_radius (float) – radius of the larger face.

  • minor_radius (float) – radius of the smaller face.

name
major_centre
direction
major_radius
minor_radius
transform
comment
centre(aabb=None)
rotation()
geant4Solid(registry, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.ELL(name, focus1, focus2, length, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Ellipsoid of Revolution

Parameters:
  • name (str) – of body

  • focus1 (list) – position [x, y, z] denoting of one of the foci.

  • focus2 (list) – position [x, y, z] denoting the other focus.

  • length (float) – length of the ellipse axis which the foci lie on.

name
focus1
focus2
length
transform
comment
semimajor
centre(aabb=None)
rotation()
_linearEccentricity()
_semiminor()
geant4Solid(greg, aabb=None)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.WED(name, vertex, edge1, edge2, edge3, transform=None, flukaregistry=None, comment='')

Bases: _WED_RAW

Right Angle Wedge

Parameters:
  • name (str) – of body

  • vertex (list) – position [x, y, z] of one of the the rectangular corners.

  • edge1 (list) – vector [x, y, z] denoting height of the wedge.

  • edge2 (list) – vector [x, y, z] denoting width of the wedge.

  • edge3 (list) – vector [x, y, z] denoting length of the wedge.

class pyg4ometry.fluka.RAW(name, vertex, edge1, edge2, edge3, transform=None, flukaregistry=None, comment='')

Bases: _WED_RAW

Base class representing a body as defined in FLUKA

__doc__
class pyg4ometry.fluka.ARB(name, vertices, facenumbers, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin

Arbitrary Convex Polyhedron

Parameters:
  • name (str) – of body

  • vertices (list) – Eight vertices which make up the polyhedron as [[x1, y1, z1], [x2, y2, z2], …]. There must be eight even if only six or seven vertices are needed to make up the polydedron.

  • facenumbers (float) – The faces of the polyhedron expressed as floats where each digit of the float refers to one of the vertices which makes up that face. Six must always be provided as [1234,8765, …], even if only four or five faces are needed. Any unneeded faces must be set to 0 (no less than 4 sides). Note that the references to the vertices are not zero-counting. The order of the vertices denoted in the facenumbers must be either all clockwise or all anticlockwise, which if not obeyed will result in erroneous output without warning.

name
vertices
facenumbers
transform
comment
_nfaces = 6
zeros = []
centre(aabb=None)
rotation()
_faceNumbersToZeroCountingIndices()
_extent()
geant4Solid(greg, aabb=None)
_toTesselatedSolid(verticesAndPolygons, greg, addRegistry)
_getVerticesAndPolygons()
_toVerticesAndPolygons(reverse)
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
class pyg4ometry.fluka.XYP(name, z, transform=None, flukaregistry=None, comment='')

Bases: _HalfSpaceMixin

Infinite half-space delimited by the x-y plane (perpendicular to the z-axis)

Parameters:
  • name (str) – of body

  • z (float) – position of the x-y plane on the z-axis. All points less than z are considered to be part of this body.

name
z
transform
comment
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
toPlane()
class pyg4ometry.fluka.XZP(name, y, transform=None, flukaregistry=None, comment='')

Bases: _HalfSpaceMixin

Infinite half-space delimited by the x-y plane (perpendicular to the y-axis)

Parameters:
  • name (str) – of body

  • y (float) – position of the x-y plane on the y-axis. All points less than y are considered to be part of this body.

name
y
transform
comment
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
toPlane()
class pyg4ometry.fluka.YZP(name, x, transform=None, flukaregistry=None, comment='')

Bases: _HalfSpaceMixin

Infinite half-space delimited by the x-y plane (perpendicular to the x-axis)

Parameters:
  • name (str) – of body

  • x (float) – position of the x-y plane on the x-axis. All points less than x are considered to be part of this body.

name
x
transform
comment
__repr__()
_withLengthSafety(safety, reg)
flukaFreeString()
hash()
toPlane()
class pyg4ometry.fluka.PLA(name, normal, point, transform=None, flukaregistry=None, comment='')

Bases: _HalfSpaceMixin

Infinite half-space delimited by the x-y plane (perpendicular to the z-axis) Generic infinite half-space.

Parameters:
  • name (str) – of body

  • normal (list) – position of a point on the plane

  • normal – vector perpendicular to the face of the plane, pointing away from the contents of the half space.

name
normal
point
transform
comment
rotation()
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
toPlane()
class pyg4ometry.fluka.XCC(name, y, z, radius, transform=None, flukaregistry=None, comment='')

Bases: _InfiniteCylinderMixin, _ShiftableCylinderMixin

Infinite Circular Cylinder parallel to the x-axis

Parameters:
  • name (str) – of body

  • y (float) – position of the centre on the

  • z (float) – position of the centre on the

  • radius (float) – position of the centre on the

name
y
z
radius
transform
comment
centre(aabb=None)
rotation()
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
point()
direction()
class pyg4ometry.fluka.YCC(name, z, x, radius, transform=None, flukaregistry=None, comment='')

Bases: _InfiniteCylinderMixin, _ShiftableCylinderMixin

Infinite Circular Cylinder parallel to the y-axis

Parameters:
  • name (str) – of body

  • z (float) – position of the centre on the

  • x (float) – position of the centre on the

  • radius (float) – position of the centre on the

name
z
x
radius
transform
comment
centre(aabb=None)
rotation()
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
point()
direction()
class pyg4ometry.fluka.ZCC(name, x, y, radius, transform=None, flukaregistry=None, comment='')

Bases: _InfiniteCylinderMixin, _ShiftableCylinderMixin

Infinite Circular Cylinder parallel to the z-axis

Parameters:
  • name (str) – of body

  • x (float) – position of the centre on the

  • y (float) – position of the centre on the

  • radius (float) – position of the centre on the

name
x
y
radius
transform
comment
centre(aabb=None)
rotation()
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
point()
direction()
class pyg4ometry.fluka.XEC(name, y, z, ysemi, zsemi, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin, _ShiftableCylinderMixin

Infinite Elliptical Cylinder parallel to the x-axis

Parameters:
  • name (str) – of body

  • y (float) – position of the centre on the

  • z (float) – position of the centre on the

  • ysemi (float) – position of the centre on the

  • zsemi (float) – position of the centre on the

name
y
z
ysemi
zsemi
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
class pyg4ometry.fluka.YEC(name, z, x, zsemi, xsemi, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin, _ShiftableCylinderMixin

Infinite Elliptical Cylinder parallel to the y-axis

Parameters:
  • name (str) – of body

  • z (float) – position of the centre on the

  • x (float) – position of the centre on the

  • zsemi (float) – position of the centre on the

  • xsemi (float) – position of the centre on the

name
z
x
zsemi
xsemi
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
class pyg4ometry.fluka.ZEC(name, x, y, xsemi, ysemi, transform=None, flukaregistry=None, comment='')

Bases: BodyMixin, _ShiftableCylinderMixin

Infinite Elliptical Cylinder parallel to the z-axis

Parameters:
  • name (str) – of body

  • x (float) – position of the centre on the

  • y (float) – position of the centre on the

  • xsemi (float) – position of the centre on the

  • ysemi (float) – position of the centre on the

name
x
y
xsemi
ysemi
transform
comment
centre(aabb=None)
rotation()
geant4Solid(reg, aabb=None)
__repr__()
_withLengthSafety(safety, reg=None)
flukaFreeString()
hash()
class pyg4ometry.fluka.QUA(name, cxx, cyy, czz, cxy, cxz, cyz, cx, cy, cz, c, transform=None, flukaregistry=None, comment='', **kwargs)

Bases: BodyMixin

Generic quadric

Parameters:
  • name (str) – of body

  • cxx (float) – x^2 coefficient

  • cyy (float) – y^2 coefficient

  • czz (float) – z^2 coefficient

  • cxy (float) – xy coefficient

  • cxz (float) – xz coefficient

  • cyz (float) – yz coefficient

  • cx (float) – x coefficient

  • cy (float) – y coefficient

  • cz (float) – z coefficient

  • c (constant) – constant

name
cxx
cyy
czz
cxy
cxz
cyz
cx
cy
cz
c
transform
comment
centre(aabb=None)
rotation()
coefficientsMatrix()
static _quadricMatrixToCoefficients(matrix)
mesh(lower, upper, capping=True)
geant4Solid(reg, aabb=None)
_withLengthSafety(safety, reg=None)
__repr__()
flukaFreeString()
hash()
pyg4ometry.fluka.infinity(inf)

Use this to temporarily modify INFINITY, with it resetting back to the default once the block has exited. INFINITY is used throughout the bodies to approximate the infinite size of infinity (elliptical) cylinders, half spaces, and quadrics.

Parameters:

inf – the value to temporarily set INFINITY to.

class pyg4ometry.fluka.Reader(filename)

Class to read a FLUKA file.

filename
flukaregistry
cards = []
getRegistry()

Get the fluka registry

_load()

Load the FLUKA input file

_findLines()
_parseBodies()
_parseRegions()
_parseCards()
_parseRotDefinis()
_parseGeometryDirective(line_parts, expansion_stack, translation_stack, transform_stack)
_parseMaterialAssignments()
_parseLattice()
_parseMaterials()
_splitMaterialCards()

Return a tuple as (Elements, Compounds, Matprop (not yet implemented)). Each is keyed with the name of the material, and the value corresponds to the card (Element) or cards (Compounds) that define the material.

class pyg4ometry.fluka.Writer

Class to write FLUKA input files from a fluka registry object.

>>> f = Writer()
>>> f.addDetectro(flukaRegObject)
>>> f.write("model.inp")
_flukaFFString = '*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+...'
addDetector(flukaRegistry)

Set the fluka registry and therefore the model for this writer instance.

write(fileName)

Write the output to a given filename. e.g. “model.inp”.

class pyg4ometry.fluka.FlukaRegistry

Object to store geometry for FLUKA input and output. All of the FLUKA classes can be used without storing them in the Registry. The registry is used to write the FLUKA output file.

bodyDict
rotoTranslations
regionDict
materials
iMaterials = 0
materialShortName
latticeDict
mgnFieldDict
cardDict
assignmas
_predefinedMaterialNames
iMerge = 0
iMergeBodies = 0
iMergeRegions = 0
iMergeMaterials = 0
_bodiesAndRegions
PhysVolToRegionMap
addBody(body)
makeBody(clas, *args, **kwargs)
getDegenerateBody(body)
addRotoTranslation(rototrans)
addRegion(region, addBodies=False)
makeRegionsDNF()
addLattice(lattice)
getBody(name)
getBodyToRegionsMap()
printDefinitions()
regionAABBs(write=None)
latticeAABBs()
addMaterial(material, recursive=False)
getMaterial(name)
addMaterialAssignments(mat, *regions, elc=None, mgn=None)
assignma(material, *regions)
addCard(card)
addTitle(title='FLUKA simulation')
addDefaults(default='EM-CASCA')
addGlobal()
addBeam(energy, energySpread=0.1, beamDivergence=0, beamWidthX=0.1, beamWidthY=0.0, annular=-1, particleType='ELECTRON')
addBeamPos(xpos=0, ypos=0, zpos=0, xdc=0, ydc=0)
addLowMat(flukaMat, lowENeutron1, lowENeutron2, lowENeutron3)
addLowMatAllMaterials()

Add LOWMAT card to all materials

addLowPwxs(what1=None, lowerMaterial=None, upperMaterial=None)
addMgnCreat()
addMgnField()
addElcField()
addUsrBin(mesh=0, particle='ENERGY', lunOutput=-21, e1max=1, e2max=1, e3max=1, name='name', e1min=-1, e2min=-1, e3min=-1, e1nbin=10, e2nbin=10, e3nbin=10)
addRotprBin(precision=0, rotDefi=0, printEventBin=0, lowerBin=None, upperBin=None)
addUsrBdx(binning, scoringDir, scoringType, type, reg1, reg2, name, area=1.0, lunOutput=-22, maxKE=None, minKE=None, nKEbin=None, maxSA=None, minSA=None, nSAbin=None)
addUsricall()
addUsrocall()
addUsrDump(mgdraw=100, lun=70, mgdrawOpt=-1, what4=0, sdum=None)
addRandomiz(seedLun=1, seed=54217137)
addStart(maxPrimHistories=1, timeTermSec=None, coreDump=None, eachHistoryOutput=None)
addPhotonuc(what1, mat_low, mat_high, mat_step, sdum='')
addMuphoton(what1, mat_low, mat_high, mat_step)
addPairbrem(what1, what2, what3, mat_low, mat_high, mat_step)
addDeltaRay(what1, what2, what3, mat_low, mat_high, mat_step, dsum='NOPRINT')
addIonFluct(what1, what2, what3, mat_low, mat_high, mat_step, dsum='PRIM-ION')
printDumps(detail=1)
findLastBodyIndex()

Find last body index (if the numbering was performed by a geant4 -> fluka conversion

findLastRegionIndex()

Find last region index (if the numbering was performed by a geant4 -> fluka conversion

findLastMaterialIndex()

Find last material index (if the numbering was performed by a geant4 -> fluka conversion

findLastTransformationIndex()
checkBodyName(bodyName)
checkRegionName(regionName)
checkMaterialName(materialName)
addRegistry(flukaRegistry, outerRegion=None, rotation=[0, 0, 0], translation=[0, 0, 0], removeRegions=[], removeRegionDependents=False)
class pyg4ometry.fluka.FlukaBodyStoreExact
nameBody
hashBody
hashName
_bodyNames()
_bodies()
make(cls, *args, **kwargs)
getDegenerateBody(body)
addBody(body)
keys()
values()
__setitem__(key, value)
__getitem__(key)
__delitem__(key)
__len__()
__contains__(key)
__iter__()
__repr__()
class pyg4ometry.fluka.Three(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)

Bases: numpy.ndarray

property x
property y
property z
parallel_to(other, tolerance=1e-10)

Check if instance is parallel to some other vector, v

unit()

Get this as a unit vector.

length()

vector length (l2 norm)

dot(other)
cross(other)
__eq__(other)
__ne__(other)
__add__(other)
__radd__(other)
__sub__(other)
__rsub__(other)
__iadd__(other)
__isub__(other)
class pyg4ometry.fluka.AABB(lower, upper)
lower
upper
size
centre
__repr__()
__eq__(other)
cornerDistance()
classmethod fromMesh(csgmesh)
intersects(other)
coplanarIntersects(other)
envelops(other)
intersect(other)
union(other)
isNull()
class pyg4ometry.fluka.Zone(name=None)

Bases: pyg4ometry.fluka.vis.ViewableMixin

Represents a zone which consists of one or more body intersections and zero or more body subtractions. May also be used to represent subzones, which are zones nested within zones, for example the form +A -B -(+C -D). Once instantiated, intersections and subtractions can be added to this instance with the addIntersection and addSubtraction method.

Parameters:

name (string) – Optional name for the zone.

intersections = []
subtractions = []
name
addSubtraction(body)

Add a body or subzone as a subtraction to this Zone instance.

Parameters:

body (Body or Zone) – Body or Zone instance.

addIntersection(body)

Add a body or subzone as an intersection to this Zone instance.

Parameters:

body – Body or Zone instance.

Type:

body: Body or Zone

convertToDNF(fluka_registry)
centre(aabb=None)
rotation()
tbxyz()
static _getSolidFromBoolean(boolean, g4reg, aabb)
mesh(aabb=None)
geant4Solid(reg, aabb=None)

Translate this zone to a geant4solid, adding the constituent primitive solids and any Booleans to the Geant4 registry. Returns the geant4 solid equivalent in geometry to this Zone.

Parameters:
  • reg (AABB or dict) – The Registry (geant4) instance to which the resulting Geant4 definitions should be added.

  • aabb – Optional reference AABB or dictionary of body name to AABB instances with which the geant4 solid should be evaluated with respect to. This is the entry point to which solid minimisation can be performed.

_combine_booleans(body0, start, collection, operation, reg, aabb)
_geant4MultiUnionSubtraction(body0, start, reg, aabb)
dumps()

Returns a string of this Zone instance in the equivalent FLUKA syntax.

dumpsDebug()

Returns a string of this Zone instance in the equivalent FLUKA syntax with extra debug information

withLengthSafety(bigger_flukareg, smaller_flukareg, shrink_intersections)
allBodiesToRegistry(flukaregistry)

Add all the bodies that contitute this Zone to the provided FlukaRegistry instance.

Parameters:

flukaregistry (FlukaRegistry) – FlukaRegistry instance to which constituent bodies will be added.

bodies()

Return the set of unique bodies that constitute this Zone.

removeBody(name)

Remove a body from this zone by name.

Parameters:

name (string) – The name of the body to be removed.

makeUnique(nameSuffix, flukaregistry)

Get this zone with every constituent body recreated with a unique name by appending nameSuffix.

Parameters:
  • nameSuffix – The string to append to the names of the bodies.

  • flukaregistry – the FlukaRegisytr instance to add the uniquely defined bodies to.

isNull(aabb=None)
toDNF(name)
isDNF()
leafCount()
class pyg4ometry.fluka.Region(name, comment='')

Bases: pyg4ometry.fluka.vis.ViewableMixin

Represents a region which consists of a region name, one or more zones, and a single material. Metadata may be provided with the comment kwarg, which is used when writing to FLUKA to provide contextual information to the physicist.

Parameters:
  • name (str) – The name of this region.

  • material (str) – The name of a material.

  • comment – Optional descriptive comment.

name
zones = []
comment
addZone(zone)

Add a Zone instance to this region.

Parameters:

zone (Zone) – The Zone instance to be added.

addIntersection(zone)
addSubtraction(zone)
extend(region)
removeNullZones()
convertToDNF(fluka_registry)
centre(aabb=None)
tbxyz()
rotation()
bodies()

Return the set of unique bodies that constitute this Zone.

mesh(aabb=None)
geant4Solid(reg, aabb=None)

Get the geant4Solid instance corresponding to this Region.

dumps()
flukaFreeString()
withLengthSafety(bigger_flukareg, smaller_flukareg)
allBodiesToRegistry(registry)

Add all the bodies that constitute this Region to the provided FlukaRegistry instance.

Parameters:

flukaregistry (FlukaRegistry) – FlukaRegistry instance to which constituent bodies will be added.

zoneGraph(zoneAABBs=None, aabb=None)
_zoneGraphPycgal()
connectedZones(zoneAABBs=None, aabb=None)
zoneAABBs(aabb=None)
aabb(aabb=None)
removeBody(name)

Remove a body from this region by name.

Parameters:

name (string) – The name of the body to be removed.

makeUnique(nameSuffix, flukaregistry)

Get this Region instance with every constituent body with a unique name by appending nameSuffix to each Body instance.

Parameters:
  • nameSuffix – string to append to each Body instance.

  • flukaregistry – FlukaRegisty instance to add each newly-defined body to.

isNull(aabb=None)
toDNF(name)
isDNF()
filterNullZones(aabb=None)
leafCount()
simplify()
__repr__()
removeZones(indices)

Remove zones by index

pyg4ometry.fluka.bracket_depth(zone)
pyg4ometry.fluka.bracket_number(zone)
pyg4ometry.fluka.zone_to_sympy(zone)
pyg4ometry.fluka.region_to_sympy(region)
pyg4ometry.fluka.sympy_to_region(sympy_expr, freg, regionName='name')

Convert sympy boolean to fluka region Must be the OR of multiple convex zones

class pyg4ometry.fluka.Transform(*, expansion=None, translation=None, rotoTranslation=None, invertRotoTranslation=None)

Bases: MatrixConvertibleMixin

expansion, translation, rotoTranslation can be either a single instance of RotoTranslation or a multiple instances of RotoTranslation and RecursiveRotoTranslation

expansion
translation
rotoTranslation
invertRotoTranslation
_expansionsTo4DMatrices()
_translationsTo4DMatrices()
_rotoTranslationsTo4DMatrices()
to4DMatrix()
class pyg4ometry.fluka.RotoTranslation(name, axis=None, polar=0.0, azimuth=0.0, translation=None, transformationIndex=None, flukaregistry=None)

Bases: MatrixConvertibleMixin

translation in mm, angles in degrees

name
axis
polar
azimuth
translation
transformationIndex
__repr__()
to4DMatrix()
toCard()
flukaFreeString()
classmethod fromCard(card)
hasTranslation()
hasRotation()
isPureTranslation()
class pyg4ometry.fluka.RecursiveRotoTranslation(name, rotoTranslations)

Bases: collections.abc.MutableSequence, MatrixConvertibleMixin

container for dealing with a recursively defined rototranslation. they must also refer to the same rototrans, i.e., have the same name. for a list of rototranslations supplied:

[a, b, c], the order of evaluation acting on a vector v is c*b*a*v. so teh first rototrans is applied first.. and so on.

name
_rtransList
names
__repr__()
__getitem__(i)
_raiseIfDifferentName(name)
__setitem__(i, obj)
__delitem__(i)
__len__()
insert(i, obj)

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

to4DMatrix()
flukaFreeString()
_transformationIndices()
areAllTheSameTransformationIndices()
property transformationIndex
class pyg4ometry.fluka.Lattice(cellRegion, rotoTranslation, invertRotoTranslation=False, flukaregistry=None)
cellRegion
rotoTranslation
invertRotoTranslation
flukaFreeString(delim=', ')
getTransform()
class pyg4ometry.fluka.Flair(flukaInputFileName='fluka.inp', extent=None)
flukaInputFileName
flukaTemplateFileName
extent
matrialColours
write(fileName)
addMaterialColour(materialName, color=(0, 0, 0, 0))
class pyg4ometry.fluka.BuiltIn(name, *, atomicNumber=None, atomicMass=None, density=None, flukaregistry=None)
name
atomicNumber
atomicMass
density
__repr__()
flukaFreeString(delim='')
class pyg4ometry.fluka.Material(name, atomicNumber, density, massNumber=None, atomicMass=None, pressure=None, flukaregistry=None, comment='')

Bases: _MatProp

A FLUKA material consisting of a single element. This corresponds to the case in FLUKA of a single MATERIAL card with no associated COMPOUND cards, as well as a possible MAT-PROP card (only if a pressure is provided, other options of MAT-PROP are unsupported).

Parameters:
  • name (str) – The name of the material

  • atomicNumber (int) – the atomic number, Z, of the element.

  • density (float) – the density in g/cm3 of the material.

  • massNumber (int, None) – Optional mass number, will be inferred in FLUKA based on atomicNumber. Allows one to specify a specific isotope.

  • atomicMass (float) – The mass of the atom in g/mole. Will be inferred in FLUKA based on atomicNumber.

  • pressure (float) – Optional pressure if the material is a gas.

  • flukaregistry (FlukaRegistry) – Optional FlukaRegistry instance the material is to be added to.

name
atomicNumber
density
atomicMass
massNumber
pressure
comment
toCards()
flukaFreeString(delim=', ')
__repr__()
classmethod fromCard(card, flukaregistry)
rename(newName, recursive=False, iIndex=0)
class pyg4ometry.fluka.Compound(name, density, fractions, fractionType, pressure=None, flukaregistry=None, comment='')

Bases: _MatProp

A FLUKA compound material. This corresponds to the case in FLUKA of a single MATERIAL card with one or more associated COMPOUND cards.

Parameters:
  • name (str) – The name of the compound.

  • density (float) – The density of the compound in g/cm3

  • fractions (list) – List of (Element, fraction) and (Compound, fraction) tuples corresponding to the fractional proportion of that material.

  • fractionType (str) – The type of the fractions listed in the fractions parameter, either atomic, mass, or volume.

  • flukaregistry (FlukaRegistry) – Optional FlukaRegistry instance the Compound is to be added to.

name
density
fractions
fractionType
pressure
comment
toCards()
flukaFreeString(delim=', ')
classmethod fromCards(cards, flukareg)
__repr__()
totalWeighting(densityWeighted=False)
rename(newName, recursive=True, iIndex=0)
class pyg4ometry.fluka.Card(keyword, what1=None, what2=None, what3=None, what4=None, what5=None, what6=None, sdum=None)

Card class for representing a FLUKA input card. To construct instances from a of FLUKA input, use the fromFree or fromFixed class method for FREE and FIXED format, respectively.

keyword
what1
what2
what3
what4
what5
what6
sdum
__repr__()
toList()
toFreeString(delim=', ')
toFixedString()
nonesToZero()

Return a class instance with same contents as this instance, but with all entries of None set to 0.0 instead.

classmethod fromFree(line)
classmethod fromFixed(line)
class pyg4ometry.fluka.Extruder(name='', length=1000, angle=0.0, regions=None, materials=None, registry=None)

Bases: pyg4ometry.geant4.solid.SolidBase

Base class for all solids

length
angle
regions
materials
cgalpolys
extrusions
decomposed
g4_extrusions
g4_decomposed_extrusions
extruders
addRegion(name, material=None)
addRegionComplete(name, pointList, material=None, scale=None, dxdy=None)
Parameters:
addExtruder(extruder)
addPointToRegion(name, pntIndx)
setRegionToOuterBoundary(name)
setRegionMaterial(name, material)
getRegionMaterial(name)
buildCgalPolygons()
buildGeant4Extrusions()
_buildStraightExtrustions()
_buildCurvedExtrusions()
plot(decompositions=False)
polygon_area(vertices)
mesh()