Compositions

Base class

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

Bases: object

Class for a composition object, which can be used to store, modify and renormalize compositions, and also convert between molar, weight, and atomic amounts.

This class is available as burnman.Composition.

renormalize(unit_type, normalization_component, normalization_amount)[source]

Change the normalization for a given unit type (weight, molar, or atomic) Resets cached composition only for that unit type

Parameters
unit_type‘weight’, ‘molar’ or ‘atomic’

Unit type composition to be renormalised

normalization_component: string

Component/element on which to renormalize. String must either be one of the components/elements already in composite, or have the value ‘total’

normalization_amount: float

Amount of component in the renormalised composition

add_components(composition_dictionary, unit_type)[source]

Add (or remove) components from the composition. The components are added to the current state of the (weight or molar) composition; if the composition has been renormalised, then this should be taken into account.

Parameters
composition_dictionarydictionary

Components to add, and their amounts, in dictionary form

unit_type‘weight’ or ‘molar’

Unit type of the components to be added

change_component_set(new_component_list)[source]

Change the set of basis components without changing the bulk composition.

Will raise an exception if the new component set is invalid for the given composition.

Parameters
new_component_listlist of strings

New set of basis components.

property molar_composition

Returns the molar composition as a counter [moles]

property weight_composition

Returns the weight composition as a counter [g]

property atomic_composition

Returns the atomic composition as a counter [moles]

print(unit_type, significant_figures=1, normalization_component='total', normalization_amount=100.0)[source]

Pretty-print function for the composition This does not renormalize the Composition internally

Parameters
unit_type‘weight’, ‘molar’ or ‘atomic’

Unit type in which to print the composition

significant_figuresinteger

Number of significant figures for each amount

normalization_component: string

Component/element on which to renormalize. String must either be one of the components/elements already in composite, or have the value ‘total’. (default = ‘total’)

normalization_amount: float

Amount of component in the renormalised composition. (default = ‘100.’)

Utility functions

burnman.classes.composition.file_to_composition_list(fname, unit_type, normalize)[source]

Takes an input file with a specific format and returns a list of compositions (and associated comments) contained in that file.

Parameters
fnamestring

Path to ascii file containing composition data. Lines beginning with a hash are not read. The first read-line of the datafile contains a list of tab or space-separated components (e.g. FeO or SiO2), followed by the word Comment. Following lines are lists of floats with the amounts of each component. After the component amounts, the user can write anything they like in the Comment section.

unit_type‘weight’ or ‘molar’

Specify whether the compositions in the file are given as weight or molar amounts.

normalizeboolean

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

Fitting functions

burnman.optimize.composition_fitting.fit_composition_to_solution(solution, fitted_variables, variable_values, variable_covariances, variable_conversions=None, normalize=True)[source]

Takes a SolidSolution object and a set of variable names and associates values and covariances and finds the molar fractions of the solution which provide the best fit (in a least-squares sense) to the variable values.

The fitting applies appropriate non-negativity constraints (i.e. no species can have a negative occupancy on a site).

Parameters
solutionburnman.SolidSolution object

The solution to use in the fitting procedure.

fitted_variableslist of strings

A list of the variables used to find the best-fit molar fractions of the solution. These should either be elements such as “Fe”, site_species such as “Fef_B” which would correspond to a species labelled Fef on the second site, or user-defined variables which are arithmetic sums of elements and/or site_species defined in “variable_conversions”.

variable_valuesnumpy array

Numerical values of the fitted variables. These should be given as amounts; they do not need to be normalized.

variable_covariances2D numpy array

Covariance matrix of the variables.

variable_conversionsdictionary of dictionaries or None

A dictionary converting any user-defined variables into an arithmetic sum of element and site-species amounts. For example, {‘Mg_equal’: {‘Mg_A’: 1., ‘Mg_B’: -1.}}, coupled with Mg_equal = 0 would impose a constraint that the amount of Mg would be equal on the first and second site in the solution.

normalizeboolean (default: True)

If True, normalizes the optimized molar fractions to sum to unity.

Returns
poptnumpy array

Optimized molar fractions.

pcov2D numpy array

Covariance matrix corresponding to the optimized molar fractions.

resfloat

The weighted residual of the fitting procedure.

burnman.optimize.composition_fitting.fit_phase_proportions_to_bulk_composition(phase_compositions, bulk_composition)[source]

Performs weighted constrained least squares on a set of phase compositions to find the amount of those phases that best-fits a given bulk composition.

The fitting applies appropriate non-negativity constraints (i.e. no phase can have a negative abundance in the bulk).

Parameters
phase_compositions2D numpy array

The composition of each phase. Can be in weight or mole amounts.

bulk_compositionnumpy array

The bulk composition of the composite. Must be in the same units as the phase compositions.

Returns
poptnumpy array

Optimized phase amounts.

pcov2D numpy array

Covariance matrix corresponding to the optimized phase amounts.

resfloat

The weighted residual of the fitting procedure.