Skip to main content

geom.select_atoms()

Select a subset of atoms.

Usage

Source

geom.select_atoms(
    geo,
    keys,
    *,
    charge=None,
    spin=None,
)

Parameters

geo: Geometry

Geometry.

keys: Sequence[int]

Indices of the atoms to keep, in the order to keep them.

charge: int | None = None

Charge of the selection. Defaults to the charge of geo.

spin: int | None = None
Spin of the selection. Defaults to the spin of geo if that is consistent with the electron count, and otherwise to the lowest consistent spin (e.g. 1 for a methyl radical selected from methane).

Returns

Geometry
The selected atoms.

Examples

    >>> geo = Geometry(
    ...     symbols=["C", "H", "H", "H", "H"],
    ...     coordinates=np.zeros((5, 3)),
    ...     charge=0,
    ...     spin=0,
    ... )
    >>> methyl = select_atoms(geo, [0, 1, 2, 3])
    >>> methyl.symbols, methyl.spin
(['C', 'H', 'H', 'H'], 1)