pyPENELOPE

materials – Material data and simulation parameters

Inheritance diagram of penelopetools.api.input.penelope.materials

class penelopetools.api.input.penelope.materials.Element(symbol, fraction=1.0)

Bases: object

Constructor of an element. Once set the symbol cannot be changed.

Parameters:
  • symbol (str) – Symbol of the element (e.g. 'Fe')
  • fraction (float) – weight fraction of the element between 0.0 and 1.0
ATTR_FRACTION = 'fraction'
ATTR_SYMBOL = 'symbol'
TAG_NAME = 'element'
atomicnumber

Atomic number of the symbol.

fraction

Weight fraction of the element between 0.0 and 1.0. The fraction can be set as a wildcard (see WILDCARD_FRACTION). The fraction will then be calculated based on all the defined elements.

classmethod from_xml(xmlelement)

Creates a Element from a XML element.

Parameters:element – XML element
has_wildcard_fraction()

Returns whether the fraction is set as the WILDCARD_FRACTION.

massdensity

Mass density in g/cm3. The value is stored in a magnitude.Magnitude.

symbol

Symbol of the element.

to_html(header_level=1)

Returns a HTML representation of this option.

to_xml()

Returns a XML representation of this option.

class penelopetools.api.input.penelope.materials.Elements(data={})

Bases: dict, misctools.base.Validable

Store the elements and their weight fraction for a material in a dictionary.

The keys corresponds to the symbols and the values to the Element objects.

ATTR_USER_DENSITY = 'userDensity_g_cm3'
TAG_NAME = 'elements'
add(symbol, fraction=1.0)

Adds a new element by defining the symbol and fraction. If the symbol of the new object Element already exists, the new object will overwrite the previous one.

add_element(element)

Adds a new element from a Element object. If the symbol of the new object element already exists, the new object will overwrite the previous one.

Parameters:element (Element) – element object
atomicfractions

Return a dictionary containing the atomic fraction of each symbol.

Return type:dict
atomicnumbers_atomicfraction_list

Return a list of tuples containing the element’s atomic number and atomic fraction.

Return type:list
atomicnumbers_weightfraction_list

Return a list of tuples containing the element’s atomic number and weight fraction.

Return type:list
chemicalformula

Returns the chemical formula from these elements.

density

Returns the density in g per cm3. If a user density is defined, it is return. If not, the mean mass density is calculated.

The value is stored in a magnitude.Magnitude.

equivalent(other, precision=8)
Compares two elements using weight fractions (regardless if they
were defined using atomic or weight fractions)
Parameters:precision – precision of the comparison (self = other \pm 10^{-precision})
static from_chemicalformula(formula)

Create a Elements from a chemical formula (e.g. 'AlB2Zr5').

static from_symbol(symbol)

Creates a Elements from a single element. The fraction is set to 1.0.

Parameters:symbol – symbol of the element.
static from_symbol_weightfraction_list(symbol_weightfraction_list)

Creates a Elements from a list of (symbol, weightFraction).

Parameters:symbol_weightfraction_list (list) – list of tuple containing the symbol and weight fraction
classmethod from_xml(xmlelement)

Creates a Elements from a XML element.

Parameters:element – XML element
has_userdensity()
has_wildcard_fraction()

Returns whether one of the element has a wildcard fraction.

mean_massdensity

Returns the mean mass density in g per cm3: \overline{\rho} = \sum_{i}^{N} \rho_{i} \cdot f_{i}^{w}

The value is stored in a magnitude.Magnitude.

setdefault(k)

Not implemented.

symbol_atomicfraction_list

Return a list of tuples containing the element’s symbol and atomic fraction.

Return type:list
symbol_weightfraction_list

Return a list of tuples containing the element’s symbol and weight fraction.

Return type:list
to_html(header_level=1)

Returns a HTML representation of this option.

to_xml()

Returns a XML representation of this option.

totalfraction

Returns the total fraction of all the elements

Return type:float
update(E, **F)

Not implemented.

userdensity

The user defined density in g per cm3. None is returned if no density is defined. If the attribute is deleted, the user defined density is ignored and the calculated density from the elements if used.

The value is stored in a magnitude.Magnitude.

validate()

Validates the elements. At least one element must be defined, and the total fraction must be equal to 1.0. Raises ValueError

weightfractions

Return a dictionary containing the weight fraction of each symbol.

Return type:dict
class penelopetools.api.input.penelope.materials.Material(name=None, filename=None, elements=None, simulation_parameters=None)

Bases: misctools.base.Validable

Constructor of an material. The material contains the elements and simulation parameters associated with the material.

Parameters:
  • name – name of the material
  • filename – filename of the material
  • elements – elements
  • simulation_parameters (SimulationParameters) – simulation parameters
ATTR_FILENAME = 'filename'
ATTR_NAME = 'name'
KEYWORD = <penelopetools.api.input.penelope.util.Keyword object at 0x5537050>
TAG_NAME = 'material'
elements

Elements of the material.

filename

Filename of the material file.

classmethod from_inputfile(lines)

Creates a Material from lines of a IN file.

Parameters:lines – lines
classmethod from_xml(element)

Creates a Material from a XML element.

Parameters:element – XML element
has_filename()
has_name()
name

Name of the material.

simulation_parameters

Simulation parameters associated with the material.

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.

validate()
class penelopetools.api.input.penelope.materials.Materials(data={})

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

Store the materials of a simulation job.

Each material is given an id representing its unique address in memory. This is referred as the id of the material. The number of material is controlled not to exceed the limits. The index represents the integer representing each material in PENELOPE.

ATTR_ID = 'id'
TAG_NAME = 'materials'
add(material, userid=None)

Adds a material and returns its id. Raises MaximumMaterialsError if the number of materials exceeds the maximum number allowed by PENELOPE.

Parameters:
  • material (Material) – material to add
  • userid – id to assign to the material. If the id is None, an automatic id is generated.
add_multiple(*materials)

Adds multiple material. An id is automatically assigned to each of them. A tuple of the ids for materials is returned. Raises MaximumMaterialsError if the number of materials exceeds the maximum number allowed by PENELOPE.

apply_simulation_parameters(params)

Sets the simulation parameters to all the materials.

Parameters:params (SimulationParameters) – simulation parameters
clear()

Removes all the materials (except the vacuum).

classmethod from_inputfile(lines)

Creates a Materials from lines of a IN file.

Parameters:lines – lines
classmethod from_xml(root)

Creates a Materials from a XML element.

Parameters:element – XML element
id_index_dict

Returns a list linking the id to the index for PENELOPE. The Vacuum material is add to the list. It’s id and index are both equal to 0. The first index is equal to 1.

Note

This list is dynamic and will changing depending on the materials added. In other words, the index for a particular id is not static.

pop(k, d=None)

Removes a material.

setdefault(k)

Not implemented.

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.

update(E, **F)

Not implemented.

validate()

Validates every material and checks that at least one material is defined. Raises ValueError.

values_novacuum()

Returns the materials without the vacuum.

Return type:list
exception penelopetools.api.input.penelope.materials.MaximumMaterialsError(value)

Bases: exceptions.Exception

Exception raised when trying to add a material passed the maximum.

class penelopetools.api.input.penelope.materials.SimulationParameters(absorption_energy_electron=50, absorption_energy_photon=50, absorption_energy_positron=50, elastic_scattering_parameter_c1=0.1, elastic_scattering_parameter_c2=0.1, cutoff_energyloss_inelasticcollisions=50, cutoff_energyloss_bremsstrahlungemission=50)

Bases: object

Store the simulation parameters for a given material.

Parameters:
  • absorption_energy_electron – absorption energy of the electrons (eV)
  • absorption_energy_photon – absorption energy of the photons (eV)
  • absorption_energy_positron – absorption energy of the positrons (eV)
  • elastic_scattering_parameter_c1 – elastic scattering parameter C1
  • elastic_scattering_parameter_c2 – elastic scattering parameter C2
  • cutoff_energyloss_inelasticcollisions – cutoff energy loss for inelastic collisions (eV)
  • cutoff_energyloss_bremsstrahlungemission – cutoff energy loss for bremsstrahlung emission (eV)
ATTR_ABS_EL = 'absorptionEnergyElectron_eV'
ATTR_ABS_PH = 'absorptionEnergyPhoton_eV'
ATTR_ABS_PO = 'absorptionEnergyPositron_eV'
ATTR_C1 = 'elasticScatteringParameter_C1'
ATTR_C2 = 'elasticScatteringParameter_C2'
ATTR_WCC = 'cutoffEnergyLossInelasticCollisions_eV'
ATTR_WCR = 'cutoffEnergyLossBremsstrahlungEmission_eV'
KEYWORD = <penelopetools.api.input.penelope.util.Keyword object at 0x55376d0>
TAG_NAME = 'simulationParameters'
absorption_energy_electron

Absorption energy of the electrons. Below this energy, electrons are no longer simulated. The energy must be between 50 and 1e6 eV. The value is stored in a magnitude.Magnitude.

absorption_energy_photon

Absorption energy of the photons. Below this energy, photons are no longer simulated. The energy must be between 50 and 1e6 eV. The value is stored in a magnitude.Magnitude.

absorption_energy_positron

Absorption energy of the positrons. Below this energy, positrons are no longer simulated. The energy must be between 50 and 1e6 eV. The value is stored in a magnitude.Magnitude.

cutoff_energyloss_bremsstrahlungemission

Cutoff energy loss for bremsstrahlung emission. The energy must be between 50 and 1e6 eV. The value is stored in a magnitude.Magnitude.

cutoff_energyloss_inelasticcollisions

Cutoff energy loss for inelastic collisions. The energy must be between 50 and 1e6 eV. The value is stored in a magnitude.Magnitude.

elastic_scattering_parameter_c1

Elastic scattering parameter C1. The value must be between 0.0 and 0.2. The value is stored in a magnitude.Magnitude.

elastic_scattering_parameter_c2

Elastic scattering parameter C2. The value must be between 0.0 and 0.2. The value is stored in a magnitude.Magnitude.

classmethod from_inputfile(lines)

Creates a SimulationParameters from lines of a IN file.

Parameters:lines – lines
classmethod from_xml(element)

Creates a SimulationParameters from a XML element.

Parameters:element – XML element
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.penelope.materials.Vacuum

Bases: penelopetools.api.input.penelope.materials.Material

Material representing the vacuum.