Filtering Structures¶
ASSYST filters are callables that accept an ase.Atoms structure and
return a bool: True to keep the structure, False to drop it.
Because filters are plain callables, they work directly with Python’s built-in
filter() function:
from assyst.filters import DistanceFilter, AspectFilter
structures = [...] # list of ase.Atoms
dist_filter = DistanceFilter({"Fe": 1.1, "N": 0.7})
good = list(filter(dist_filter, structures))
Any callable with the signature (Atoms) -> bool is accepted wherever a
Filter is expected — including plain functions and
lambdas:
# keep only structures with at least 4 atoms
good = list(filter(lambda s: len(s) >= 4, structures))
Composing filters¶
FilterBase subclasses support & (and) and |
(or) to build compound filters without nesting explicit
AndFilter / OrFilter
instances:
combined = DistanceFilter({"Fe": 1.1}) & AspectFilter(maximum_aspect_ratio=5)
good = list(filter(combined, structures))
The & operator short-circuits: the right-hand filter is only evaluated if
the left-hand filter returns True.
Available filter classes¶
Class |
What it checks |
|---|---|
Minimum interatomic distances (element-pair cutoffs) |
|
Maximum aspect ratio of the unit cell (longest / shortest lattice parameter) |
|
Maximum volume per atom |
|
Energy per atom within |
|
Maximum atomic force magnitude (requires a single-point |
See assyst.filters for the full API reference of each class.