PENELOPE¶
Base classes¶
Definition of base classes.
-
class
pypenelopetools.penelope.base.
InputLineBase
[source]¶ Bases:
object
Base class to parse and read PENELOPE text files.
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 44¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_create_line
(name, values, comment='')[source]¶ Creates an input line of this keyword from the specified text. 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: Returns: Formatted line.
Return type:
-
_parse_line
(line)[source]¶ Extracts the keyword, the values and the comment of an input line. The values are returned as a list.
Parameters: line (str) – Input line. Returns: Keyword, values, comment. Return type: tuple(str, tuple(str), str)
-
_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_next_line
(fileobj)[source]¶ Returns the next line and advances the current position. Comment line (line starting with 7 spaces) are automatically skipped.
Parameters: fileobj (file object) – File object opened with read access. Returns: Next line, stripped of all trailing white spaces. Return type: str
-
Definition of base keyword classes.
-
class
pypenelopetools.penelope.keyword.
KeywordBase
[source]¶ Bases:
pypenelopetools.penelope.base.InputLineBase
Base of all PENELOPE keywords.
-
name
¶ str – Name of keyword.
-
-
class
pypenelopetools.penelope.keyword.
KeywordGroupBase
[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordBase
Group of keywords, keywords that should always be defined together.
-
name
¶ str – Name of keyword.
-
-
class
pypenelopetools.penelope.keyword.
KeywordSequence
(keyword, maxlength)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordBase
Sequence of keywords, keywords that can be defined multiple times.
Parameters: - keyword (KeywordBase) – Base keyword.
- maxlength (int) – Maximum number of keywords that can be added.
-
add
(*args)[source]¶ Adds a new keyword definition. This internally creates a new keyword based on the base keyword, sets the value(s) and add it to a list.
Parameters: *args – Value(s).
-
name
¶ str – Name of keyword.
-
class
pypenelopetools.penelope.keyword.
TypeKeyword
(name, types, comment='')[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordBase
Keyword where the
type
of the values are checked.Parameters: -
comment
¶ str – Comment.
-
name
¶ str – Name of keyword.
-
read
(fileobj)[source]¶ Reads a PENELOPE-type file.
Parameters: fileobj (file object) – File object opened with read access.
-
Definition of base separator classes.
-
class
pypenelopetools.penelope.separator.
Separator
(text, name='')[source]¶ Bases:
pypenelopetools.penelope.base.InputLineBase
Base of all PENELOPE separators.
Parameters: -
text
¶ str – Comment of the separator
-
name
¶ str, optional – name of separator keyword (e.g. END)
-
Definition of base input classes.
-
class
pypenelopetools.penelope.input.
PenelopeInputBase
[source]¶ Bases:
pypenelopetools.penelope.base.InputLineBase
Base input class.
Definition of base result classes.
Keywords¶
Keywords used across different PENELOPE main programs.
-
class
pypenelopetools.penelope.keywords.
DSMAX
(maxlength=5000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Maximum step length of electrons and positrons in body.
Note
This parameter is important only for thin bodies; it should be given a value of the order of one tenth of the body thickness or less.
-
class
pypenelopetools.penelope.keywords.
DUMPP
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Dump interval.
When the DUMPTO option is activated, simulation results are written in the output files every DUMPP seconds. This option is useful to check the progress of long simulations. It also allows the program to be run with a long execution time and to be stopped when the required statistical uncertainty has been reached.
-
class
pypenelopetools.penelope.keywords.
DUMPTO
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Name of dump file.
Generate a dump file named ‘dump2.dmp’ after completing the simulation run. This allows the simulation to be resumed later on to improve statistics.
Note
If the file ‘dump2.dmp’ already exists, it is overwritten.
-
class
pypenelopetools.penelope.keywords.
EABSB
(maxlength=5000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Local absorption energies EABSB(KPAR,KB) of particles of type KPAR in body KB.
These values must be larger than EABS(KPAR,M), where M is the material of body KB. When the particle is moving within body KB, the absorption energy EABS(KPAR,M) is temporarily set equal to EABSB(KPAR,KB). Thus, the simulation of the particle history is discontinued when the energy becomes less than EABSB(KPAR,KB). This feature can be used, e.g., to reduce the simulation work in regions of lesser interest.
-
class
pypenelopetools.penelope.keywords.
EDSPC
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Name of the output spectrum file.
-
class
pypenelopetools.penelope.keywords.
ENDETC
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of an energy-deposition detector.
-
set
(el, eu, nbe)[source]¶ Sets energy limits.
Parameters: - el (float) – Lower limit in eV.
- eu (float) – Upper limit in eV.
- nbe (int) – Number of bins in the output energy distribution. Should be less than 1000. If NBE is positive, energy bins have uniform width, DE=(EU-EL)/NBE. When NBE is negative, the bin width increases geometrically with the energy, i.e., the energy bins have uniform width on a logarithmic scale.
-
-
class
pypenelopetools.penelope.keywords.
GEOMFN
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Name of geometry definition file.
The bodies in the material structure are normally identified by the sequential labels assigned by PENGEOM. For complex geometries, however, it may be more practical to employ user labels, i.e., the four-character strings that identify the body in the geometry definition file. In PENMAIN (and only in the parts of the code that follow the definition of the geometry), a body can be specified by giving either its PENGEOM numerical label or its user label enclosed in a pair of apostrophes (e.g., ‘BOD1’). However, bodies that result from the cloning of modules (as well as those defined in an INCLUDEd geometry file) do not have a user label and only the PENGEOM numerical label is acceptable.
-
class
pypenelopetools.penelope.keywords.
GRIDX
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of x-coordinates of the vertices of the dose box.
-
class
pypenelopetools.penelope.keywords.
GRIDY
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of y-coordinates of the vertices of the dose box.
-
class
pypenelopetools.penelope.keywords.
GRIDZ
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of z-coordinates of the vertices of the dose box.
-
class
pypenelopetools.penelope.keywords.
IBRSPL
(maxlength=5000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Bremsstrahlung splitting for electrons and positrons.
Note
Note that bremsstrahlung splitting is applied in combination with interaction forcing and, consequently, it is activated only in those bodies where interaction forcing is active.
-
class
pypenelopetools.penelope.keywords.
IXRSPL
(maxlength=5000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Splitting of characteristic x rays emitted.
Each unsplit x ray with ILB(2)=2 (i.e., of the second generation) when extracted from the secondary stack is split into IXRSPL quanta. The new, lighter, quanta are assigned random directions distributed isotropically.
-
class
pypenelopetools.penelope.keywords.
InteractionForcings
(maxlength=120000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Forcing of interactions.
FORCER is the forcing factor, which must be larger than unity. WLOW and WHIG are the lower and upper limits of the pweight window where interaction forcing is applied. When several interaction mechanisms are forced in the same body, the effective weight window is set equal to the intersection of the windows for these mechanisms.
If the mean free path for real interactions of type ICOL is MFP, the program will simulate interactions of this type (real or forced) with an effective mean free path equal to MFP/FORCER.
Hint
A negative input value of FORCER, -FN, is assumed to mean that a particle with energy E=EPMAX should interact, on average, +FN times in the course of its slowing down to rest, for electrons and positrons, or along a mean free path, for photons. This is very useful, e.g., to generate x-ray spectra from bulk samples.
-
class
pypenelopetools.penelope.keywords.
MFNAME
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Name of a PENELOPE input material data file.
This file must be generated in advance by running the program MATERIAL.
-
class
pypenelopetools.penelope.keywords.
MSIMPA
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Set of simulation parameters for this material
- absorption energies, EABS(1:3,M),
- elastic scattering parameters, C1(M) and C2(M), and
- cutoff energy losses for inelastic collisions and Bremsstrahlung emission, WCC(M) and WCR(M).
-
set
(eabs1, eabs2, eabs3, c1, c2, wcc, wcr)[source]¶ Sets parameters.
Parameters: - eabs1 (float) – Absorption energy of electrons in eV.
- eabs2 (float) – Absorption energy of photons in eV.
- eabs3 (float) – Absorption energy of positrons in eV.
- c1 (float) – Elastic scattering coefficient.
- c2 (float) – Elastic scattering coefficient.
- wcc (float) – Cutoff energy losses for inelastic collisions in eV.
- wcr (float) – Cutoff energy losses for Bremsstrahlung emission in eV.
-
class
pypenelopetools.penelope.keywords.
MaterialGroup
[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordGroupBase
Group to define both material file name and its simulation parameters.
-
set
(filename, eabs1, eabs2, eabs3, c1, c2, wcc, wcr, index=None)[source]¶ Sets material file name and simulation parameters.
Parameters: - filename (str) – File name of material file (up to 20 characters).
- eabs1 (float) – Absorption energy of electrons in eV.
- eabs2 (float) – Absorption energy of photons in eV.
- eabs3 (float) – Absorption energy of positrons in eV.
- c1 (float) – Elastic scattering coefficient.
- c2 (float) – Elastic scattering coefficient.
- wcc (float) – Cutoff energy losses for inelastic collisions in eV.
- wcr (float) – Cutoff energy losses for Bremsstrahlung emission in eV.
- index (int, optional) – Index of this material in the geometry
-
-
class
pypenelopetools.penelope.keywords.
Materials
(maxlength=10)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Definition of materials.
-
add
(index, filename, eabs1, eabs2, eabs3, c1, c2, wcc, wcr)[source]¶ Adds a new material.
Parameters: - index (int) – Index of this material in the geometry
- filename (str) – File name of material file (up to 20 characters).
- eabs1 (float) – Absorption energy of electrons in eV.
- eabs2 (float) – Absorption energy of photons in eV.
- eabs3 (float) – Absorption energy of positrons in eV.
- c1 (float) – Elastic scattering coefficient.
- c2 (float) – Elastic scattering coefficient.
- wcc (float) – Cutoff energy losses for inelastic collisions in eV.
- wcr (float) – Cutoff energy losses for Bremsstrahlung emission in eV.
-
-
class
pypenelopetools.penelope.keywords.
NBANGL
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of angular distributions of emerging particles.
Note
In the output files, the terms ‘upbound’ and ‘downbound’ are used to denote particles that leave the material system moving upwards (W>0) and downwards (W<0), respectively.
-
set
(nbth, nbph)[source]¶ Sets angular distributions.
Parameters: - nbth (int) – Numbers of bins for the polar angle THETA. Should be less than 3600. If NBTH is positive, angular bins have uniform width, DTH=180./NBTHE. When NBTH is negative, the bin width increases geometrically with THETA, i.e., the bins have uniform width on a logarithmic scale.
- nbph (int) – Number of bins for the azimuthal angle PHI Should be less than 180.
-
-
class
pypenelopetools.penelope.keywords.
NBE
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Definition of energy distributions of emerging particles.
-
set
(el, eu, nbe)[source]¶ Sets energy distributions.
Parameters: - el (float) – Lower limit in eV.
- eu (float) – Upper limit in eV.
- nbe (int) – Number of bins in the output energy distribution. Should be less than 1000. If NBE is positive, energy bins have uniform width, DE=(EU-EL)/NBE. When NBE is negative, the bin width increases geometrically with the energy, i.e., the energy bins have uniform width on a logarithmic scale.
-
-
class
pypenelopetools.penelope.keywords.
NSIMSH
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Desired number of simulated showers.
-
class
pypenelopetools.penelope.keywords.
RESUME
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Name of the resume file.
The program will read the dump file named
dump1.dmp
and resume the simulation from the point where it was left.Warning
Use this option very, VERY carefully. Make sure that the input data file is fully consistent with the one used to generate the dump file.
-
class
pypenelopetools.penelope.keywords.
RSEED
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Seeds of the random-number generator.
-
set
(iseed1, iseed2)[source]¶ Sets seeds.
Parameters: - iseed1 (int) – First seed. When ISEED1 is equal to a negative integer, -N, the seeds are set by calling subroutine RAND0(N) with the input argument equal to N. This ensures that sequences of random numbers used in different runs of the program (with different values of N) are truly independent.
- iseed2 (int) – Second seed.
-
-
class
pypenelopetools.penelope.keywords.
SCONE
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Initial direction of primary particles is sampled uniformly within a conical beam.
Conical source beam. Polar and azimuthal angles of the beam axis direction, THETA and PHI, and angular aperture, ALPHA, in deg.
The case ALPHA=0 defines a monodirectional source, and ALPHA =180 deg corresponds to an isotropic source.
-
class
pypenelopetools.penelope.keywords.
SENERG
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
For a monoenergetic source, initial energy SE0 of primary particles.
-
class
pypenelopetools.penelope.keywords.
SGPOL
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Activates the simulation of polarisation effects in the scattering of photons.
This line activates the simulation of polarisation effects in the scattering of photons (electrons and positrons are assumed to be unpolarised). SP1, SP2, SP3 are the Stokes parameters of primary photons, which define the degrees of linear polarisation at 45 deg azimuth, of circular polarisation, and of linear polarisation at zero azimuth, respectively. It is assumed that secondary photons are emitted with null polarisation (SP1=SP2=SP3=0).
-
class
pypenelopetools.penelope.keywords.
SKPAR
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Type of primary particle KPARP (1=electrons, 2=photons or 3=positrons).
If KPARP=0, the initial states of primary particles are set by subroutine SOURCE, to be provided by the user. An example of that subroutine, corresponding to a 60-Co source (two gamma rays in each nuclear deexcitation), is included in the PENMAIN package (file ‘source.f’).
-
class
pypenelopetools.penelope.keywords.
SPECTR
(maxlength=1000)[source]¶ Bases:
pypenelopetools.penelope.keyword.KeywordSequence
Define a source with continuous (stepwise constant) spectrum.
For a source with continuous (stepwise constant) spectrum, each ‘SPECTR’ line gives the lower end-point of an energy bin of the source spectrum (Ei) and the associated relative probability (Pi), integrated over the bin. Up to NSEM=1000 lines, in arbitrary order. The upper end of the spectrum is defined by entering a line with Ei equal to the upper energy end point and with a negative Pi value.
-
class
pypenelopetools.penelope.keywords.
SPOSIT
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Coordinates of the source centre.
-
class
pypenelopetools.penelope.keywords.
SRECTA
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Initial direction of primary particles is sampled uniformly within a rectangular beam.
Rectangular source beam. Limiting polar and azimuthal angles of the source beam window, (THETAL,THETAU)x(PHIL,PHIU), in deg.
The case THETAL=THETAU, PHIL=PHIU defines a monodirectional source. To define an isotropic source, set THETAL=0, THETAU= 180, PHIL=0 and PHIU=360.
-
class
pypenelopetools.penelope.keywords.
TIME
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Allotted simulation time.
-
class
pypenelopetools.penelope.keywords.
TITLE
[source]¶ Bases:
pypenelopetools.penelope.keyword.TypeKeyword
Title of the job.
The TITLE string is used to mark dump files. To prevent the improper use of wrong resuming files, change the title each time you modify basic parameters of your problem. The code will then be able to identify the inconsistency and to print an error message before stopping.
Separators¶
Separators used across different PENELOPE main programs.
-
pypenelopetools.penelope.separators.
BREMSSTRAHLUNG_SPLITTING
= <pypenelopetools.penelope.separator.Separator object>¶ Section for Bremsstralung splitting.
-
pypenelopetools.penelope.separators.
DOT
= <pypenelopetools.penelope.separator.Separator object>¶ Section separator.
-
pypenelopetools.penelope.separators.
EMERGING_PARTICLES
= <pypenelopetools.penelope.separator.Separator object>¶ Section for emerging particles.
-
pypenelopetools.penelope.separators.
END
= <pypenelopetools.penelope.separator.Separator object>¶ End separator
-
pypenelopetools.penelope.separators.
ENERGY_DEPOSITON_DETECTORS
= <pypenelopetools.penelope.separator.Separator object>¶ Section for energy deposition detectors.
-
pypenelopetools.penelope.separators.
INTERACTION_FORCING
= <pypenelopetools.penelope.separator.Separator object>¶ Section for interaction forcing(s).
-
pypenelopetools.penelope.separators.
JOB_PROPERTIES
= <pypenelopetools.penelope.separator.Separator object>¶ Section for job properties.
-
pypenelopetools.penelope.separators.
MATERIAL
= <pypenelopetools.penelope.separator.Separator object>¶ Section for material(s).
-
pypenelopetools.penelope.separators.
SOURCE_DEFINITION
= <pypenelopetools.penelope.separator.Separator object>¶ Section for source definition.
-
pypenelopetools.penelope.separators.
XRAY_SPLITTING
= <pypenelopetools.penelope.separator.Separator object>¶ Section for characteristic x ray splitting.