chemistry – alloy chemistry

Module for handeling alloying and particle content.

class pario.chemistry.Chemistry(symbols, weight_fractions=None, atom_fractions=None, balance=0, particles=None, **kw)[source]

Class representing the chemical composition (including particles) of an alloying system.

Parameters :

symbols : string | sequence of strings | record array

Sequence with chemical symbols of all elements. Alternatively a string of the form “AlMg0.5Si0.6” might be provided. If neither weight_fractions or atom_fractions are given, the composition (in weight percent) will be derived from it.

weight_fractions : floats array

Nominal concentrations corresponding to symbols, wt fraction Cannot be given together with atom_fractions.

atom_fractions : floats array

Nominal concentrations corresponding to symbols, at fraction Cannot be given together with weight_fractions.

balance : int | string

Index or symbol of the dependent element. It’s amount will be calculated.

particles : sequence of Particle instances

Description of particles.

kw : keyword_arguments

The keyword arguments must be arrays of same length as symbols and might be used to assosiate additional information to the elements.

Examples

>>> chem = Chemistry(symbols=['Al', 'Si', 'Mg', 'Fe'],
...                  weight_fractions=[0., 0.0043, 0.0048, 0.0020])
>>> chem.weight_fractions
array([ 0.9889,  0.0043,  0.0048,  0.002 ])

Same example, weight percent is assumed

>>> chem = Chemistry('AlSi0.43Mg0.48Fe0.2')
>>> chem.weight_fractions
array([ 0.9889,  0.0043,  0.0048,  0.002 ])
add_atom_array(name, array, unit=None)[source]

Add array to atom arrays with name name. If an array of the same name already exists, it is replaced.

add_element(symbol, weight_fraction=None, atom_fraction=None, **kw)[source]

Add element. Default amount is zero. Keyword arguments must correspond to additional arrays.

add_particle(particle)[source]

Add Particle object particle.

atom_fractions

Array of atom fractions.

balance

Index of dependent element.

copy()[source]

Returns a copy of self.

get_element_record(fields=None)[source]

Return a record array with the chemistry. Fields gives the fields to include. It defaults to [‘Element’, ‘C0(wt%)’] followed by all additional arrays.

The following fields are recognised:

element/symbol/atom :
Atomic symbols.
c0/c/conc :
Nominal concentration. Recognised units are “at%”, “wt%”, “at fraction”, “wt fraction”. Default unit is at fraction.
M/molar_mass :
Molar mass.
get_element_table(fields=None, linesep=None)[source]

Returns element table with columns given by fields. Defaults to [‘Element’, ‘C0(wt%)’] plus all added arrays. See also get_element_record().

get_particle_record(fields=None, shortname=True)[source]

Returns information on all particles as a record array with columns given by fields. Defaults to [‘Particle’, ‘f’] plus additional scalar information common to all particles.

If fields is None and shortname is True, the shortest alias is used for column names.

get_particle_table(fields=None, linesep=None)[source]

Returns particle table with columns given by fields. Defaults to [‘Particle’, ‘f’] plus additional scalar information common to all particles.

get_solute(unit='at_fractions')[source]

Returns an array with solute solution amounts. Valid units are “at_fractions”, “at%”, “wt_fractions” and , “wt%”.

get_zener_drag(gamma_GB=0.3, C_PZ=None)[source]

Returns Zener drag in Pascal for all particles. gamma_GB is the grain boundary energy in J/m^2. C_PZ is an array of pre-factors for each particle. If not given it defaults to unity.

isvalid()[source]

Returns true if nominal and solute concentrations are in valid range.

particles

Direct access to list of Particle objects.

remove_atom_array(name=None)[source]

Remove atom array. If name is None, all atom arrays are removed.

remove_element(symbol)[source]

Remove given element.

remove_particle(name)[source]

Remove given particle.

set(chem)[source]

Set this chemistry object to equal chem.

set_atom_fraction(element, atom_fraction)[source]

Set atom fraction given element. element might be the atomic symbol of an existing element or its index.

set_atom_fractions(symbols, atom_fractions, balance=0)[source]

Set atom fractions.

set_weight_fraction(element, weight_fraction)[source]

Set weight fraction given element. element might be the atomic symbol of an existing element or its index.

set_weight_fractions(symbols, weight_fractions, balance=0)[source]

Set weight fractions.

symbols

List of atomic symbols.

tostring()[source]

Returns composition in weight percent as a string.

volume_fractions

Array of particle volume fractions.

weight_fractions

Array of weight fractions.

write(fname, linesep=None)[source]

Write chemistry to file. fname can either be a file object or a file name.

exception pario.chemistry.ChemistryError[source]

Base exception for chemistry.

class pario.chemistry.Particle(name, composition=None, volume_fraction=0.0, sizes=None, relative_standard_deviation=None, size_distribution=None, number_density=None, **kw)[source]

Class representing a particle.

Parameters :

name : string

Name of particle type, e.g. “Al6Mn”, “Mg5Si4Al2”, “beta’‘”.

composition : None, string | dict | record_array | sequence_of_tuples

Particle composition. All amounts are relative. Can be specified in the following formats:

  • None, the composition determined from the particle name

  • string, e.g. “Al6Mn”

  • dict mapping element names to amount, e.g. {‘Al’: 6, ‘Mn’: 1}

  • record array, e.g.:

    array([(6, 1)], dtype=[('Al', '<i8'), ('Mn', '<i8')])
    
  • sequence of tuples, e.g. [(‘Al’, 6), (‘Mn’, 1)]

volume_fraction : float

Particle volume fraction.

sizes : float | array

Particle sizes in units of meter (midpoint of size classes). A single float is interpreated as the mean size.

relative_standard_deviation : None | float

Relative standard deviation of the particle size, i.e. the standard deviation devided by the mean particle size (also known as coefficient of variance). Only used when size_distribution is not None.

size_distribution : None | “lognormal” | “lognorm” | “exp”

Size distribution. If given, sizes must a single float.

number_density : float | array

Particle number density in units of number per m^3. Array must be of same length as sizes.

kw : keyword_arguments

The keyword arguments gives additional info about the particle and is stored in a dict accessible via the info property. Exceptions are the following aliases:

  • particle -> name
  • f, volfrac, “volume fraction” -> volume_fraction
  • r, size -> sizes
  • relstd -> relative_standard_deviation
  • distr, distribution -> size_distribution
  • n, “number density” -> number_density

Examples

>>> p = Particle('Al3Ti', f=0.011, molar_volume=26.21e-5)
>>> print(p.composition)
[('Al', 3) ('Ti', 1)]
>>> p.composition.dtype.names
('species', 'amounts')
>>> p.info
{'molar_volume': 0.0002621}
amounts

Amount of each species in atom fractions.

atom_fractions(symbols=None)[source]

Returns an array with the atom fraction of each specie in symbols. If symbols is None, self.species is used.

Examples

>>> p = Particle('Al3Ti')
>>> p.atom_fractions(['Ti', 'Al', 'Cu'])
array([ 0.25,  0.75,  0.  ])
composition

Direct access to record array with composition.

copy()

Returns a copy of self.

get_info_labels()[source]

Returns a list of labels associated with the info property.

get_info_names()[source]

Returns a list of attribute names associated with the info property.

get_info_units()[source]

Returns a list of units for attributes associated with the info property. An empty string is returned for attributes without unit.

get_zener_drag(gamma_GB=0.3, C_PZ=None)[source]

Returns Zener drag in Pascal for this particle. gamma_GB is the grain boundary energy in J/m^2 and C_PZ is a pre-factor that defaults to unity.

has(label)[source]

Returns true if label is a valid indexing key.

info

Dict with additional properties assigned to the particle.

name

Name of particle type.

number_density

Direct access to array of particle number density for each size class, #/m^3.

plot(fig=None)

Returns a matplotlib figure object with size distributions plotted.

set_composition(composition)[source]

Sets particle composition.

set_name(name, defines_composition=False)[source]

Set particle name. If defines_composition is true, the composition is updated based on the name.

sizes

Direct access to array of size class midpoints, m.

species

List of atom species the particle is composed of.

symbol()[source]

Returns composition as a string.

volume_fraction

Particle volume fraction.

pario.chemistry.at2wt(symbols, atom_fractions, balance=0)[source]

Converts atom fractions to weight fractions.

Examples

>>> at2wt(['Al', 'Si', 'Mg', 'Fe'], [0.0, 0.0043, 0.0048, 0.0020]) # AA6060
array([ 0.98708433,  0.00446772,  0.00431591,  0.00413204])
pario.chemistry.from_particle_table(particle_table)[source]

Returns a list of Particle objects from Numpy record array particle_table.

pario.chemistry.fromfile(filename, balance=0)[source]

Read chemistry from filename. Returns a Chemistry object.

pario.chemistry.fromrecords(rec, balance=0)[source]

Return a Chemistry object from numpy record array.

Recognised fields (case insensitive):

element/ele/symbol/atom :
Atomic symbols.
c0/conc/nominal conc :
Nominal concentration. Recognised units are “at%”, “wt%”, “at fraction”, “wt fraction”. Default unit is at fraction.

Other fields are simply added to the chemistry as-is.

pario.chemistry.fromstring(string, balance=0)[source]

Parse string with an Alpack ELEMENT_TABLE and return a Chemistry object.

pario.chemistry.parse_composition(name)[source]

Returns a sequence of (symbol, number)-tuples from parsing the particle name name.

Examples

>>> parse_composition('Al6Mn')
[('Al', 6), ('Mn', 1)]
>>> parse_composition('He')
[('He', 1)]
>>> parse_composition('H2')
[('H', 2)]
>>> parse_composition('K')
[('K', 1)]
>>> parse_composition('AlMg0.5Si0.6')
[('Al', 1), ('Mg', 0.5), ('Si', 0.6)]
pario.chemistry.wt2at(symbols, weight_fractions, balance=0)[source]

Converts weight fractions to atom fractions.

Examples

>>> wt2at(['Al', 'Si', 'Mg', 'Fe'], [0.0, 0.0043, 0.0048, 0.0020]) # AA6060
array([  9.89567130e-01,   4.13376624e-03,   5.33218526e-03,
         9.66918268e-04])

Previous topic

variables – track model variables through execution

Next topic

case – describe a modelling case

This Page