A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://smact.readthedocs.io/en/latest/examples/filter.html below:

Using filter — smact

Using filter#

The smact_filter function from the smact.screening module screens possible combinations of elements in a chemical system. It applies chemical rules to filter and return valid compositions.

In the following example, we apply smact_filter to a combination of elements to find valid compositions within a stoichiometry threshold.

import smact
from smact.screening import smact_filter
import pprint

# Define a list of elements to screen
elements = ["Ti", "Ga", "O"]

# Convert element symbols into smact.Element objects
element_objects = [smact.Element(e) for e in elements]

# Apply smact_filter to find valid compositions within a stoichiometry threshold
allowed_combinations = smact_filter(element_objects, threshold=3)

# Display the allowed combinations in a readable format
pprint.pprint("(elements), (charges), (stoichiometry)")
pprint.pprint(allowed_combinations)
'(elements), (charges), (stoichiometry)'
[(('Ti', 'Ga', 'O'), (1, 1, -2), (1, 1, 1)),
 (('Ti', 'Ga', 'O'), (1, 1, -2), (1, 3, 2)),
 (('Ti', 'Ga', 'O'), (1, 1, -2), (3, 1, 2)),
 (('Ti', 'Ga', 'O'), (1, 1, -1), (1, 1, 2)),
 (('Ti', 'Ga', 'O'), (1, 1, -1), (1, 2, 3)),
 (('Ti', 'Ga', 'O'), (1, 1, -1), (2, 1, 3)),
 (('Ti', 'Ga', 'O'), (1, 2, -2), (2, 1, 2)),
 (('Ti', 'Ga', 'O'), (1, 2, -2), (2, 2, 3)),
 (('Ti', 'Ga', 'O'), (1, 2, -1), (1, 1, 3)),
 (('Ti', 'Ga', 'O'), (1, 3, -2), (1, 1, 2)),
 (('Ti', 'Ga', 'O'), (1, 3, -2), (3, 1, 3)),
 (('Ti', 'Ga', 'O'), (2, 1, -2), (1, 2, 2)),
 (('Ti', 'Ga', 'O'), (2, 1, -2), (2, 2, 3)),
 (('Ti', 'Ga', 'O'), (2, 1, -1), (1, 1, 3)),
 (('Ti', 'Ga', 'O'), (2, 2, -2), (1, 1, 2)),
 (('Ti', 'Ga', 'O'), (2, 2, -2), (1, 2, 3)),
 (('Ti', 'Ga', 'O'), (2, 2, -2), (2, 1, 3)),
 (('Ti', 'Ga', 'O'), (3, 1, -2), (1, 1, 2)),
 (('Ti', 'Ga', 'O'), (3, 1, -2), (1, 3, 3)),
 (('Ti', 'Ga', 'O'), (3, 3, -2), (1, 1, 3)),
 (('Ti', 'Ga', 'O'), (4, 1, -2), (1, 2, 3)),
 (('Ti', 'Ga', 'O'), (4, 2, -2), (1, 1, 3))]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4