wulfric.crystal.get_atoms_species#

wulfric.crystal.get_atoms_species(atoms, raise_on_fail=False) str[source]#

Attempts to identify atoms species based on their names (i.e. Cr1 -> Cr, ...).

If no species is identified, then return "X".

Parameters:
atomsdict

Dictionary with N atoms. Expected keys:

  • "names" : (N, ) list of str

raise_on_failbool, default False

Whether to raise an exception if automatic species deduction fails.

Returns:
speciesstr

Species of the atom.

Raises:
FailedToDeduceAtomSpecies

If raise_on_fail = True and automatic species deduction fails.

Warning

If raise_on_fail = True and automatic species deduction fails, then RuntimeWarning is issued, and atom species is set to "X".

See also

get_atom_species

Notes

If atoms["names"][i] contains several possible atom species of length 2 as substrings, then the species is equal to the first one found.

Examples

>>> import wulfric
>>> atoms = dict(names=["Fe1", "Fe2", "Cr", "Br3"])
>>> wulfric.crystal.get_atoms_species(atoms)
['Fe', 'Fe', 'Cr', 'Br']
>>> atoms = {"names": ["Cr1", "cr2", "Br3", "S4", "fe5", "Fe6"]}
>>> wulfric.crystal.get_atoms_species(atoms)
['Cr', 'Cr', 'Br', 'S', 'Fe', 'Fe']