Building lists

Building lists#

Often when using smact the aim will be to search over combinations of a set of elements. This is most efficiently achieved by setting up a dictionary of the elements that you want to search over. The easiest way to achieve this in :mod:smact is to first create a list of the symbols of the elements that you want to include, then to build a dictionary of the corresponding element objects.

The list can be built by hand, or if you want to cover a given range there is a helper function.

import smact

elements = smact.ordered_elements(13, 27)
print(elements)
['Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co']

For doing searches across combinations of elements it is then quickest to load the element objects into a dictionary and search by key. This avoids having to repopulate the element class at each iteration of the search.

element_list = smact.element_dictionary(elements)
print(element_list)
{'Al': <smact.Element object at 0x7fdffaf2a7c0>, 'Si': <smact.Element object at 0x7fe0383e83a0>, 'P': <smact.Element object at 0x7fe03857b8e0>, 'S': <smact.Element object at 0x7fe0384618e0>, 'Cl': <smact.Element object at 0x7fe0383f17c0>, 'Ar': <smact.Element object at 0x7fe03845d130>, 'K': <smact.Element object at 0x7fe0383e9fa0>, 'Ca': <smact.Element object at 0x7fe038459430>, 'Sc': <smact.Element object at 0x7fe0384597f0>, 'Ti': <smact.Element object at 0x7fe0384599a0>, 'V': <smact.Element object at 0x7fe038459190>, 'Cr': <smact.Element object at 0x7fe038704d30>, 'Mn': <smact.Element object at 0x7fe038704ac0>, 'Fe': <smact.Element object at 0x7fe038704c40>, 'Co': <smact.Element object at 0x7fe038704b20>}