Chemical symbols¶
- class ase.symbols.Symbols(numbers)[source]¶
A sequence of chemical symbols.
atoms.symbols
is aase.symbols.Symbols
object. This object works like an editable view ofatoms.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.- 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])}