Skip to content

Species index function

Simone Sturniolo requested to merge stur86/ase:species-index-function into master

Moved and slightly changed two functions, _get_number_in_species and _get_absolute_number, from the CASTEP calculator to the main Atoms object, as they were labelled in comments as such and could indeed work well. Now renamed:

get_index_in_species accepts an index of an atom and returns the index of that atom in an array composed only of the other atoms of the same species. For example:

a = Atoms(['H', 'H', 'C', 'H'])
print(a.get_index_in_species(3))

prints 2. Raises a ValueError for invalid indices.

get_global_index takes a species symbol and an integer and works in reverse, finding the global index. Raises a RuntimeError if no fitting atom is found.

Merge request reports