PENEPMA

Input

Input of PENEPMA simulation.

class pypenelopetools.penepma.input.PenepmaInput[source]

Bases: pypenelopetools.penelope.input.PenelopeInputBase

Creates an object representing a PENEPMA input file.

TITLE

TITLE – Title of the job (up to 65 characters).

SKPAR

SKPAR – Type of primary particle KPARP (1=electrons, 2=photons or 3=positrons).

SENERG

SENERG – Initial energy SE0 of primary particles.

SPOSIT

SPOSIT – Coordinates of the source centre.

SRADI

SRADI – Initial position of the particle is sampled randomly within a circle.

SDIREC

SDIREC – Polar and azimuthal angles of the electron beam axis direction.

SAPERT

SAPERT – Angular aperture of the electron beam.

materials

Materials – Definition of materials.

GEOMFN

GEOMFN – Name of geometry definition file.

DSMAX

DSMAX – Maximum step length of electrons and positrons in body.

IFORCE

IFORCE – Forcing of interactions.

IBRSPL

IBRSPL – Bremsstrahlung splitting for electrons and positrons.

IXRSPL

IXRSPL – Splitting of characteristic x rays emitted.

NBE

NBE – Definition of energy distributions of emerging particles.

NBANGL

NBANGL – Definition of angular distributions of emerging particles.

photon_detectors

PhotonDetectors – Definition of the photon detectors.

GRIDX

GRIDX – Definition of x-coordinates of the vertices of the dose box.

GRIDY

GRIDY – Definition of y-coordinates of the vertices of the dose box.

GRIDZ

GRIDZ – Definition of z-coordinates of the vertices of the dose box.

XRAYE

XRAYE – Space distribution of emission sites of x rays within an energy interval.

XRLINE

XRLINE – Space distribution of emission sites of x rays.

RESUME

RESUME – Name of the resume file.

DUMPTO

DUMPTO – Name of dump file.

DUMPP

DUMPP – Dump interval.

RSEED

RSEED – Seeds of the random-number generator.

REFLIN

REFLIN – Termination of simulation based on relative statistical uncertainty of the intensity of line.

NSIMSH

NSIMSH – Desired number of simulated showers.

TIME

TIME – Allotted simulation time.

get_keywords()[source]

Returns: list: Sorted list of all keywords in the input.

read(fileobj)

Reads an input file (i.e. .in).

Parameters:fileobj (file object) – File object opened with read access.
write(fileobj)

Writes to an input file (i.e. .in).

Parameters:fileobj (file object) – File object opened with write access.

Results

Results of PENEPMA simulation.

class pypenelopetools.penepma.results.PenepmaIntensityResult(detector_index)[source]

Bases: pypenelopetools.penepma.results.PenepmaPhotonDetectorResultBase

Results from pe-intens-XX.dat, where XX is the index of the detector. The intensities are given for each characteristic x-ray detected by the detector.

Note

The characteristic x-rays are expressed using XrayLine object of the pyxray package. XrayLine objects define the atomic number and x-ray transition of characteristic x-rays.

The intensities are expressed using the uncertainties package. The nominal value can be accessed with the property nominal_value or the abbreviation n, whereas the standard deviation (1-sigma), with the property std_dev or s.

For example:

import pyxray
x = pyxray.XrayLine(29, 'Ka1')
result.total_intensities_1_per_sr_electron[x].n #-> 8.56e-10
result.total_intensities_1_per_sr_electron[x].s #-> 0.15e-10
Parameters:detector_index (int) – Index of the detector to read the results from.
detector_index

int – Index of detector

theta1_deg

ufloat – Lower limit polar angle in deg.

theta2_deg

ufloat – Upper limit polar angle in deg.

phi1_deg

ufloat – Lower limit azimuthal angle in deg.

phi2_deg

ufloat – Upper limit azimuthal angle in deg.

primary_intensities_1_per_sr_electron

dict(XrayLine, ufloat) – Intensities of characteristic x-rays generated by primary electrons and measured by the detector.

characteristic_fluorescence_intensities_1_per_sr_electron

dict(XrayLine, ufloat) – Intensities of characteristic x-rays generated by the fluorescence of characteristic x-rays and measured by the detector.

bremsstrahlung_fluorescence_intensities_1_per_sr_electron

dict(XrayLine, ufloat) – Intensities of characteristic x-rays generated by the fluorescence of Bremsstrahlung x-rays and measured by the detector.

total_fluorescence_intensities_1_per_sr_electron

dict(XrayLine, ufloat) – Intensities of characteristic x-rays generated by fluorescence (characteristic and Bremsstrahlung) and measured by the detector. Intensities are equal to the sum of characteristic_fluorescence_intensities_1_per_sr_electron and bremsstrahlung_fluorescence_intensities_1_per_sr_electron.

total_intensities_1_per_sr_electron

dict(XrayLine, ufloat) – Intensities of characteristic x-rays generated and measured by the detector. Intensities are equal to the sum of primary_intensities_1_per_sr_electron and total_fluorescence_intensities_1_per_sr_electron.

read(fileobj)[source]

Reads a result file.

Parameters:fileobj (file object) – File object opened with read access.
read_directory(dirpath)[source]

Read a result file from a directory.

Parameters:dirpath (str) – Path of a directory.
class pypenelopetools.penepma.results.PenepmaPhotonDetectorResultBase(detector_index)[source]

Bases: pypenelopetools.penelope.result.PenelopeResultBase

Base result associated with a photon detector.

Parameters:detector_index (int) – Index of the detector to read the results from.
detector_index

int – Index of detector

theta1_deg

ufloat – Lower limit polar angle in deg.

theta2_deg

ufloat – Upper limit polar angle in deg.

phi1_deg

ufloat – Lower limit azimuthal angle in deg.

phi2_deg

ufloat – Upper limit azimuthal angle in deg.

read(fileobj)[source]

Reads a result file.

Parameters:fileobj (file object) – File object opened with read access.
read_directory(dirpath)

Read a result file from a directory.

Parameters:dirpath (str) – Path of a directory.
class pypenelopetools.penepma.results.PenepmaResult[source]

Bases: pypenelopetools.penelope.result.PenelopeResultBase

Results from penepma-res.dat.

Note

All results are expressed using the uncertainties package. The nominal value can be accessed with the property nominal_value or the abbreviation n, whereas the standard deviation (1-sigma), with the property std_dev or s. For example:

result.simulation_time_s.n #-> 100.0
result.simulation_time_s.s #-> 0.0
simulation_time_s

ufloat – Simulation time in seconds.

simulation_speed_1_per_s

ufloat – Simulation speed in simulation per second.

simulated_primary_showers

ufloat – Number of primary showers simulated.

upbound_primary_particles

ufloat – Number of primary particles that exited the geometry upwards.

downbound_primary_particles

ufloat – Number of primary particles that exited the geometry downwards.

absorbed_primary_particles

ufloat – Number of primary particles that were absorbed within the geometry.

upbound_fraction

ufloat – Fraction of primary particles that exited the geometry upwards.

downbound_fraction

ufloat – Fraction of primary particles that exited the geometry downwards.

absorbed_fraction

ufloat – Fraction of primary particles that were absorbed within the geometry.

upbound_secondary_electron_generation_probabilities

ufloat – Probability of second generation electrons exited the geometry upwards.

downbound_secondary_electron_generation_probabilities

ufloat – Probability of second generation electrons exited the geometry downwards.

absorbed_secondary_electron_generation_probabilities

ufloat – Probability of second generation electrons absorbed within the geometry.

upbound_secondary_photon_generation_probabilities

ufloat – Probability of second generation photons exited the geometry upwards.

downbound_secondary_photon_generation_probabilities

ufloat – Probability of second generation photons exited the geometry downwards.

absorbed_secondary_photon_generation_probabilities

ufloat – Probability of second generation photons absorbed within the geometry.

upbound_secondary_positron_generation_probabilities

ufloat – Probability of second generation positrons exited the geometry upwards.

downbound_secondary_positron_generation_probabilities

ufloat – Probability of second generation positrons exited the geometry downwards.

absorbed_secondary_positron_generation_probabilities

ufloat – Probability of second generation positrons absorbed within the geometry.

average_deposited_energy_eV

dict(int, ufloat) – Average deposited energy in each body. Dictionary where keys are indexes of body and values, the average deposited energy in eV.

average_photon_energy_eV

dict(int, ufloat) – Average photon energy in each detector. Dictionary where keys are indexes of detector and values, the average energy in eV.

last_random_seed1

ufloat – Last first seed of the random number generator.

last_random_seed2

ufloat – Last second seed of the random number generator.

reference_line_uncertainty

ufloat – Relative uncertainty of the x-ray line used as a termination condition

read(fileobj)[source]

Reads a result file.

Parameters:fileobj (file object) – File object opened with read access.
read_directory(dirpath)[source]

Read a result file from a directory.

Parameters:dirpath (str) – Path of a directory.
class pypenelopetools.penepma.results.PenepmaSpectrumResult(detector_index)[source]

Bases: pypenelopetools.penepma.results.PenepmaPhotonDetectorResultBase

Results from pe-spect-XX.dat, where XX is the index of the detector. The spectrum is stored as a numpy array where the first column contains the energies in eV and the second the intensities in 1/(sr.electron).

Note

The energies and intensities are expressed using the uncertainties package. The nominal value can be accessed with the property nominal_value or the abbreviation n, whereas the standard deviation (1-sigma), with the property std_dev or s.

For example:

from uncertainty import unumpy
energies_eV = unumpy.nominal_values(result.spectrum[:,0])
intensities = unumpy.nominal_values(result.spectrum[:,1])
Parameters:detector_index (int) – Index of the detector to read the results from.
detector_index

int – Index of detector

theta1_deg

ufloat – Lower limit polar angle in deg.

theta2_deg

ufloat – Upper limit polar angle in deg.

phi1_deg

ufloat – Lower limit azimuthal angle in deg.

phi2_deg

ufloat – Upper limit azimuthal angle in deg.

energy_window_start_eV

ufloat – Energy of first window in eV.

energy_window_end_eV

ufloat – Energy of last window in eV.

channel_width_eV

ufloat – Width of one channel in eV.

spectrum

unumpy.uarray – Array where the first column contains the energies in eV and the second the intensities measured by the detector in 1/(sr.electron).

energies_eV

numpy array – Nominal values of the energy axis in eV.

intensities_1_per_sr_electron

numpy array – Nominal values of the intensity axis in 1/(sr.electron).

read(fileobj)[source]

Reads a result file.

Parameters:fileobj (file object) – File object opened with read access.
read_directory(dirpath)[source]

Read a result file from a directory.

Parameters:dirpath (str) – Path of a directory.

Keywords

Keywords used specifically for PENEPMA.

class pypenelopetools.penepma.keywords.PhotonDetectorGroup[source]

Bases: pypenelopetools.penelope.keyword.KeywordGroupBase

Definition of photon detector.

Each detector collects photons that leave the sample with directions within a rectangle( on the unit sphere, limited by the *parallels THETA1 and THETA2 and the meridians PHI1 and PHI2. The output spectrum is the energy distribution of photons that emerge within the acceptance solid angle of the detector with energies in the interval from EDEL to EDEU, recorded using NCHE channels. Notice that the spectrum is given in absolute units (per incident electron, per eV and per unit solid angle).

get_keywords()[source]

Returns: tuple: Keywords apart of this group.

set(theta1, theta2, phi1, phi2, ipsf, edel, edeu, nche, emission_filename=None)[source]

Sets parameters of detector.

Note

phi1 and phi2 must be both either in the interval (0,360) or in the interval (-180,180).

Parameters:
  • theta1 (float) – Lower limit polar angle in deg.
  • theta2 (float) – Upper limit polar angle in deg.
  • phi1 (float) – Lower limit azimuthal angle in deg.
  • phi2 (float) – Upper limit azimuthal angle in deg.
  • ipsf (int) –

    Flag to activate the creation of a phase-space file (psf), which contains the state variables and weights of particles that enter the detector. Use this option with care, because psf’s may grow very fast.

    • ipsf=0: the psf is not created.
    • ipsf=1: a psf is created.
    • ipsf>1: a psf is created, but contains only state variables of detected photons that have ILB(4)=IPSF (used for studying angular distributions of x rays).

    Generating the psf is useful for tuning interaction forcing, which requires knowing the weights of detected particles.

  • edel (float) – Lower limits of the energy window covered by the detector in eV.
  • edeu (float) – Upper limits of the energy window covered by the detector in eV.
  • nche (int) – Number of energy channels in the output spectrum. Should be less than 1000.
  • emission_filename (str, optional) – File name of the generation file. Specifying a file name activates the generation of a file with the position coordinates of the emission sites of the photons that reach the detector. Notice that the file may grow very fast, so use this option only in short runs. The output file is overwritten when a simulation is resumed.
class pypenelopetools.penepma.keywords.PhotonDetectors(maxlength=25)[source]

Bases: pypenelopetools.penelope.keyword.KeywordSequence

Definition of the photon detectors.

Up to 25 different detectors can be defined.

add(theta1, theta2, phi1, phi2, ipsf, edel, edeu, nche, emission_filename=None)[source]

Add a new photon detector.

Note

phi1 and phi2 must be both either in the interval (0,360) or in the interval (-180,180).

Important

The theta angles are defined as angles from the positive z-axis. This is different than the take-off angle usually used in microanalysis. For a take-off angle of 30deg, theta would be 60deg.

Parameters:
  • theta1 (float) – Lower limit polar angle in deg.
  • theta2 (float) – Upper limit polar angle in deg.
  • phi1 (float) – Lower limit azimuthal angle in deg.
  • phi2 (float) – Upper limit azimuthal angle in deg.
  • ipsf (int) –

    Flag to activate the creation of a phase-space file (psf), which contains the state variables and weights of particles that enter the detector. Use this option with care, because psf’s may grow very fast.

    • ipsf=0: the psf is not created.
    • ipsf=1: a psf is created.
    • ipsf>1: a psf is created, but contains only state variables of detected photons that have ILB(4)=IPSF (used for studying angular distributions of x rays).

    Generating the psf is useful for tuning interaction forcing, which requires knowing the weights of detected particles.

  • edel (float) – Lower limits of the energy window covered by the detector in eV.
  • edeu (float) – Upper limits of the energy window covered by the detector in eV.
  • nche (int) – Number of energy channels in the output spectrum. Should be less than 1000.
  • emission_filename (str, optional) – File name of the generation file. Specifying a file name activates the generation of a file with the position coordinates of the emission sites of the photons that reach the detector. Notice that the file may grow very fast, so use this option only in short runs. The output file is overwritten when a simulation is resumed.
class pypenelopetools.penepma.keywords.REFLIN[source]

Bases: pypenelopetools.penelope.keyword.TypeKeyword

Termination of simulation based on relative statistical uncertainty of the intensity of line.

set(izs1s200, idet, tol)[source]

Sets termination.

Hint

Use convert_xrayline_to_izs1s200 to convert XrayLine to ILB(4) notation.

Parameters:
  • izs1s200 – x ray identification. ILB(4) notation, note the final double zero (IZ*1e6+S1*1e4+S2*1e2).
  • idet (int) – Index of detector.
  • tol (float) – Relative statistical uncertainty (3*sigma) of the intensity of line
class pypenelopetools.penepma.keywords.SAPERT[source]

Bases: pypenelopetools.penelope.keyword.TypeKeyword

Angular aperture of the electron beam.

set(salpha)[source]

Sets angle.

Parameters:salpha (float) – Angular aperture in deg.
class pypenelopetools.penepma.keywords.SDIREC[source]

Bases: pypenelopetools.penelope.keyword.TypeKeyword

Polar and azimuthal angles of the electron beam axis direction.

set(stheta, sphi)[source]

Sets angles.

Parameters:
  • stheta (float) – Polar angle in deg.
  • sphi (float) – Azimuthal angle in deg.
class pypenelopetools.penepma.keywords.SRADI[source]

Bases: pypenelopetools.penelope.keyword.TypeKeyword

Initial position of the particle is sampled randomly within a circle.

The circle is centered at (SX0,SY0,SZ0) and perpendicular to the beam axis direction.

set(sradius)[source]

Sets circle.

Parameters:sradius (float) – Radius of the circle in cm.
class pypenelopetools.penepma.keywords.XRAYE(maxlength=10)[source]

Bases: pypenelopetools.penelope.keyword.KeywordSequence

Space distribution of emission sites of x rays within an energy interval.

add(emin, emax)[source]

Add an energy interval.

Parameters:
  • emin (float) – Lower limit in eV.
  • emax (float) – Upper limit in eV.
class pypenelopetools.penepma.keywords.XRLINE(maxlength=10)[source]

Bases: pypenelopetools.penelope.keyword.KeywordSequence

Space distribution of emission sites of x rays.

add(izs1s200)[source]

Adds a characteristic x ray.

Hint

Use convert_xrayline_to_izs1s200 to convert XrayLine to ILB(4) notation.

Parameters:izs1s200 (int) – x ray identification. ILB(4) notation, note the final double zero (IZ*1e6+S1*1e4+S2*1e2).