shnitsel.geo.geocalc#

This module contains functionality to calculate certain geometric features from positional data found within datasets. Through the use of structural selection support from the shnitsel.filtration module, specifically StructureSelection, the set of featueres to calculate can be restricted.

Functions#

get_centered_geometry(atXYZ[, by_mass])

Helper function to set the center of the geometry (i.e. mean along the atom axis) to zero.

kabsch(atXYZ[, reference_or_indexers])

Rotationally align the molecular geometries in atXYZ to a single molecular geometry.

get_bats(…)

Get bond lengths, angles and torsions/dihedrals.

Module Contents#

get_centered_geometry(atXYZ, by_mass=False)#

Helper function to set the center of the geometry (i.e. mean along the atom axis) to zero.

Parameters:
  • atXYZ (AtXYZ) – Array of positional data

  • by_mass (Literal[False], optional) – Flag whether the centering/average should be center of mass or just plain average of positions. Defaults to False.

Raises:

NotImplementedError – Centering the COM instead of the mean is currently not implemented.

Returns:

Resulting positions after centering.

Return type:

AtXYZ

kabsch(atXYZ, reference_or_indexers=None, **indexers_kwargs)#

Rotationally align the molecular geometries in atXYZ to a single molecular geometry.

If no reference_or_indexers argument (or the indexers_kwargs option) is passed, this function will try to use the first frame or first timestep in atXYZ as a reference.

Parameters:
  • atXYZ (xr.DataArray) – The geometries to process (with dims ‘atom’, ‘direction’)

  • reference_or_indexers (xr.DataArray | dict, optional) – Either a reference geometry (with dims ‘atom’, ‘direction’) or an indexer dictionary which will be passed to atXYZ.sel() to indetify a single geometry in the atXYZ parameter to use as a reference point.

  • **indexer_kwargs – The keyword-argument form of the indexer to be passed to atXYZ.sel()

Returns:

The aligned geometries

Return type:

xr.DataArray

Raises:

ValueError – If nothing is done to indicate a reference geometry, i.e. neither reference_or_indexers nor indexer_kwargs are passed

get_bats(atXYZ: shnitsel.data.dataset_containers.shared.ShnitselDataset | xarray.Dataset | shnitsel.core.typedefs.AtXYZ, structure_selection: shnitsel.filtering.structure_selection.StructureSelection | shnitsel.filtering.structure_selection.StructureSelectionDescriptor | None = None, default_features: Sequence[shnitsel.filtering.structure_selection.FeatureLevelType] = ['bonds', 'angles', 'dihedrals'], signed: bool = False, deg: bool | Literal['trig'] = True) xarray.DataArray#
get_bats(atXYZ: shnitsel.data.tree.ShnitselDB[shnitsel.data.dataset_containers.shared.ShnitselDataset | xarray.Dataset | shnitsel.core.typedefs.AtXYZ], structure_selection: shnitsel.filtering.structure_selection.StructureSelection | shnitsel.filtering.structure_selection.StructureSelectionDescriptor | None = None, default_features: Sequence[shnitsel.filtering.structure_selection.FeatureLevelType] = ['bonds', 'angles', 'dihedrals'], signed: bool = False, deg: bool | Literal['trig'] = True) shnitsel.data.tree.ShnitselDB[xarray.DataArray]

Get bond lengths, angles and torsions/dihedrals.

Parameters:
  • atXYZ (Trajectory | Frames | TreeNode[Any, Trajectory | Frames] | AtXYZ) – The positional data of atoms to use.

  • structure_selection (StructureSelection | StructureSelectionDescriptor, optional) – A feature selection to use. Can specify which features (positions, distances, angles, torsions or pyramidalizations) to include in the result. If not set, will be initialized to a default selection of all molecule-internal features as specified by the structure in the first frame of atXYZ and the features listed in default_features.

  • default_features (Sequence[FeatureLevelType], optional) – If no structure_selection object is provided, will select all features of these levels within the structure encoded in atXYZ. Options are - atoms for positional data, - bonds for distances between pairs of atoms (defaults to only bonds) - angles for angles between pairs of bonds between atoms. - dihedrals for torsion angles of bonds - pyramids for pyramidalization angles in the molecule. Defaults to using bonds, angles and dihedrals/torsions.

  • signed (bool, optional) – Whether to distinguish between clockwise and anticlockwise rotation, when returning angles as opposed to cosine & sine values; by default, do not distinguish. NB. This applies only to the dihedrals, not to the three-center angles. The latter are always unsigned.

  • deg (bool or Literal['trig'], optional) – If True (the default), returns angles in degrees. If False, returns angles in radians. If set to ‘trig’ returns sines and cosines;

Returns:

An xarray.DataArray containing bond lengths, angles and tensions.

Return type:

xr.DataArray | TreeNode[Any, xr.DataArray]

Examples

>>> import shnitsel as st
>>> from shnitsel.geo import geocalc
>>> data = st.read('/test_data/shnitsel/traj_I02.nc')
>>> geocalc.get_bats(data)