Composition Class

class burnman.classes.composition.Composition(composition_dictionary, unit_type='mass', normalize=False)[source]

Bases: object

The Composition class can be used to store, modify and renormalize compositions, and also convert between mass, molar and atomic amounts. Weight is provided as an alias for mass, as we assume that only Earthlings will use this software.

Composition can parse dictionaries of components, rather than only elements. Components are given as strings (e.g. ‘MgSiO3’, ‘Fe2O3’, etc). The Composition class breaks these components down into their elemental constituents internally.

Example:

from burnman.composition import Composition

comp_dict = {'MgSiO3': 0.5, 'FeSiO3': 0.5}
comp = Composition(comp_dict, unit_type='molar', normalize=True)
print(comp.atomic_composition)

# Renormalize to 1 kg of material
comp.renormalize(unit_type='mass', normalization_component='total', normalization_amount=1.0)
print(comp.mass_composition)

# Add 0.1 moles of Al2O3 to the composition
comp.add_components({'Al2O3': 0.1}, unit_type='molar')
print(comp.molar_composition)

# Change the component set to only oxides
comp.change_component_set(['MgO', 'SiO2', 'FeO', 'Al2O3'])
print(comp.molar_composition)

# Remove components with less than 1.e-10 moles
comp.remove_null_components(tol=1.e-10)
print(comp.molar_composition)

# Pretty-print the molar composition, normalized to 100 moles total
comp.print(unit_type='molar', significant_figures=3, normalization_component='total', normalization_amount=100.0)
Parameters:
  • composition_dictionary (dictionary) – Dictionary of components (given as a string) and their amounts.

  • unit_type (str) – ‘mass’, ‘weight’ or ‘molar’ (optional, ‘mass’ as default) Specify whether the input composition is given as mass or molar amounts.

  • normalize (bool) – If False, absolute numbers of kilograms/moles of component are stored, otherwise the component amounts of returned compositions will sum to one (until Composition.renormalize() is used).