wulfric.crystal.get_atom_species#
- wulfric.crystal.get_atom_species(name: str, raise_on_fail=False) str[source]#
Attempts to identify atom's species based on its name (i.e. Cr1 -> Cr, ...).
If no species is identified, then return "X".
- Parameters:
- namestr
Name of the atom.
- 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 = Trueand automatic species deduction fails.
Warning
If
raise_on_fail = Trueand automatic species deduction fails, thenRuntimeWarningis issued, and atom species is set to "X".See also
Notes
If
namecontains several possible atom species of length 2 as substrings, then the species is equal to the first one found.Examples
>>> from wulfric.crystal import get_atom_species >>> get_atom_species("@%^#$") 'X' >>> get_atom_species("Cr") 'Cr' >>> get_atom_species("Cr1") 'Cr' >>> get_atom_species("_3341Cr") 'Cr' >>> get_atom_species("cr") 'Cr' >>> get_atom_species("S") 'S' >>> get_atom_species("Se") 'Se' >>> get_atom_species("Sp") 'S' >>> get_atom_species("123a") 'X' >>> get_atom_species("CrSBr") 'Cr'