Chemical symbols

class ase.symbols.Symbols(numbers)[source]

A sequence of chemical symbols.

atoms.symbols is a ase.symbols.Symbols object. This object works like an editable view of atoms.numbers, except its elements are manipulated as strings.

Examples:

>>> from ase.build import molecule
>>> atoms = molecule('CH3CH2OH')
>>> atoms.symbols
Symbols('C2OH6')
>>> atoms.symbols[:3]
Symbols('C2O')
>>> atoms.symbols == 'H'  
array([False, False, False,  True,  True,  True,  True,  True,  True]...)
>>> atoms.symbols[-3:] = 'Pu'
>>> atoms.symbols
Symbols('C2OH3Pu3')
>>> atoms.symbols[3:6] = 'Mo2U'
>>> atoms.symbols
Symbols('C2OMo2UPu3')
>>> atoms.symbols.formula
Formula('C2OMo2UPu3')

The ase.formula.Formula object is useful for extended formatting options and analysis.

property formula: Formula

Formula object.

get_chemical_formula(mode: str = 'hill', empirical: bool = False) str[source]

Get chemical formula.

See documentation of ase.atoms.Atoms.get_chemical_formula().

indices() Dict[str, Union[Sequence[int], ndarray]][source]

Return dictionary mapping each unique symbol to indices.

>>> from ase.build import molecule
>>> atoms = molecule('CH3CH2OH')
>>> atoms.symbols.indices()
{'C': array([0, 1]), 'O': array([2]), 'H': array([3, 4, 5, 6, 7, 8])}
search(symbols) Union[Sequence[int], ndarray][source]

Return the indices of elements with given symbol or symbols.

species() Set[str][source]

Return unique symbols as a set.

species_indices() Sequence[int][source]

Return the indices of each atom within their individual species.

>>> from ase import Atoms
>>> atoms = Atoms('CH3CH2OH')
>>> atoms.symbols.species_indices()
[0, 0, 1, 2, 1, 3, 4, 0, 5]

^ ^ ^ ^ ^ ^ ^ ^ ^ C H H H C H H O H