tqchem.batframe

Classes

Bond

Class representing a bond between two atoms

Angle

Class representing an angle between three atoms

Dihedral

Class representing an dihedral/torsion angle between four atoms

InversionDihedral

Class representing a dihedral used for Nitrogen inversion

BATFrame

Class/Dictionary storing the bonds, angles and dihedrals and their values

Functions

bond_mask(→ list[int])

List of atom indices that should be changed together with the given bond

angle_mask(→ list[int])

List of atom indices that should change together with the given angle

dihedral_mask(→ list[int])

Get a list of atom indices that should rotate together with the given dihedral

masked_coordinate(→ Bond | Angle | Dihedral)

Return copy of coordinate containing its appropriate mask

is_proper_dihedral(→ bool)

Does a dihedral represent a rotation around an actual bond

is_improper_dihedral(→ bool)

Does a dihedral represent a rotation around an actual bond

torsion_from_bond(→ dict[Dihedral, float])

Get a Dihedral that rotates the subsituents of an entire bond

rotatable_bonds(→ list[tuple[int, int]])

Determine rotatable bonds from graph representation of molecule

xyz_to_bat(→ BATFrame)

Transform XYZ to BAT coordinates

bat_to_xyz(→ tqchem.molgraph.MolecularSystem)

Transform BAT to XYZ coordinates

improper_dihedral_path_ring(→ list[int])

Get path for improper dihedral angle in a ring

get_dihedral_path(→ list[int])

Get path to create dihedral angle for a given atom from MolGraph

bat_component(→ BATFrame)

Constructor for a BATFrame with values set to None

nitrogen_inversion(→ None | dict[InversionDihedral, float])

Return dihedral describing nitrogen inversion

Module Contents

class tqchem.batframe.Bond

Bases: tuple

Class representing a bond between two atoms

based on the tuple class a bond is described by the uid of the 2 atoms involved

tuple

containing uid of atom 0 and atom 1

tqchem.batframe.bond_mask(bond: Bond, open_graph: networkx.Graph) list[int]

List of atom indices that should be changed together with the given bond

The mask should contain the last atom of the bond (the one moved) and the connected atoms that rotate with it. This mask is passed to set_bond of ase.Atoms

class tqchem.batframe.Angle

Bases: tuple

Class representing an angle between three atoms

based on the tuple class an angle is described by the indices of the 3 atoms involved

tuple

containing uids of atom0 to atom2

tqchem.batframe.angle_mask(angle: Angle, open_graph: networkx.Graph) list[int]

List of atom indices that should change together with the given angle

The mask should contain the last atom of the angle (the one moved) and the connected atoms that should move with it. This mask is passed to set_angle of ase.Atoms

class tqchem.batframe.Dihedral

Bases: tuple

Class representing an dihedral/torsion angle between four atoms

based on the tuple class a dihedral is described by the indices of the 4 atoms involved

tuple

containing uids of atom0 to atom3

class tqchem.batframe.InversionDihedral

Bases: Dihedral

Class representing a dihedral used for Nitrogen inversion

Dummy class to make Dihedrals used for nitrogen inversion distinguishable and to save the 2 dihedral values defining the “normal” and “inverted” state

tqchem.batframe.dihedral_mask(dih: Dihedral, open_graph: networkx.Graph) list[int]

Get a list of atom indices that should rotate together with the given dihedral

The mask should contain the atom that is rotated around which we rotate and the connected atoms that rotate with it. This mask is passed to set_dihedral of ase.Atoms

tqchem.batframe.masked_coordinate(coordinate: Bond | Angle | Dihedral, open_graph: networkx.Graph) Bond | Angle | Dihedral

Return copy of coordinate containing its appropriate mask

class tqchem.batframe.BATFrame

Bases: dict

Class/Dictionary storing the bonds, angles and dihedrals and their values

For a given set of atoms this class contains the information required construct a conformer or a frame of an MD trajectory.

Torsions are implemented as Dihedrals with a mask rotating all atoms attached to the end of a given bond.

angles(self):

return dictionary relating the angles of the frame to their size

bonds(self):

return dictionary relating the bonds of the frame to their lengths

dihedrals(self):

return dictionary relating the dihedrals of the frame to their size

copy(self):

return a copy of the BATFrame

angles() BATFrame

Return dictionary of all angles and their sizes

bonds() BATFrame

Return dictionary of all bonds and their lengths

dihedrals() BATFrame

Return dictionary of all dihedrals and their sizes

copy() BATFrame

Return copy of the BATFrame

torsions_from_bonds(bonds: list[tuple[int, int]], molecule: tqchem.molgraph.MolecularSystem, component: list[int]) BATFrame

Find torsions from list of bonds

variable_coordinates(molecule: tqchem.molgraph.MolecularSystem, atom_order: list[int], component: list[int]) BATFrame

Determine rotatable bonds and collect torsions

constant_coordinates(molecule: tqchem.molgraph.MolecularSystem) BATFrame

Determine constant coordinates

These coordinates have to be reset after changing variable bonds. This includes for example bond lengths and angles

grid: _typeshed.Incomplete
make_grid(graph: networkx.Graph, shift_by_reference: bool = False) None

Discretize all torsions in the frame

evaluate_grid(indices: list[int]) BATFrame

Evaluate the frame at a given grid index

grid_range() list[range]

Return the grid range for all torsions in the frame

closest_gridpoint(molecule: tqchem.molgraph.MolecularSystem) list[int]

Return the gridpoint most similar to the provided molecule

__add__(value: float) BATFrame
__sub__(value: float) BATFrame
tqchem.batframe.is_proper_dihedral(dihedral: Dihedral, graph: networkx.Graph) bool

Does a dihedral represent a rotation around an actual bond

tqchem.batframe.is_improper_dihedral(dihedral: Dihedral, graph: networkx.Graph) bool

Does a dihedral represent a rotation around an actual bond

tqchem.batframe.torsion_from_bond(bond: Bond, frame: BATFrame, graph: networkx.Graph) dict[Dihedral, float]

Get a Dihedral that rotates the subsituents of an entire bond

The rotation around a bond is achieved by adding all substituents of the second atom of the bond to a mask such that they are rotated together

Parameters:
  • bond (Bond) – Bond for which dihedrals should be found

  • frame (BATFrame) – Dictionary mapping Bonds, Angles, Dihedrals to values

  • graph (nx.Graph) – Open graph representing the molecule

Return type:

dict[Dihedral, float]

tqchem.batframe.rotatable_bonds(graph: networkx.Graph) list[tuple[int, int]]

Determine rotatable bonds from graph representation of molecule

tqchem.batframe.xyz_to_bat(mol: tqchem.molgraph.MolecularSystem, frame: BATFrame) BATFrame

Transform XYZ to BAT coordinates

Parameters:
  • mol (MolecularSystem) – Molecule as represented in tqchem

  • frame (BATFrame) – BATFrame specifying the atoms involved in the BATcoordinates

Returns:

frame – frame with overwritten values for the BATCoordinates

Return type:

BATFrame

tqchem.batframe.bat_to_xyz(mol: tqchem.molgraph.MolecularSystem, frame: BATFrame) tqchem.molgraph.MolecularSystem

Transform BAT to XYZ coordinates

Parameters:
  • mol (MolecularSystem) – Molecule as represented in tqchem

  • frame (BATFrame) – Internal coordinates (defined by atom indices) and their values

Returns:

new_molecule – Molecule with geometry updated based on the BATFrame

Return type:

MolecularSystem

tqchem.batframe.improper_dihedral_path_ring(cycle: tuple[int, Ellipsis], connecting_atom: int) list[int]

Get path for improper dihedral angle in a ring

tqchem.batframe.get_dihedral_path(component: tuple[int, Ellipsis], component_sweep: list[tuple[int, Ellipsis]], molgraph: tqchem.molgraph.MolecularSystem, atom: int, root: int, improper_ring_dihedral: bool = True) list[int]

Get path to create dihedral angle for a given atom from MolGraph

Based on a tree graph, the path to create a dihedral angle for a given atom is determined.

Parameters:
  • component (tuple[int, ...]) – atoms for the component of the whole molecule

  • component_sweep (list[tuple[int, ...]) – list of components

  • molgraph (MolecularSystem) – Molecular graph and ase.Atoms object

  • atom (int) – atom to which the dihedral path leads

  • root (int) – root of the path

  • improper_ring_dihedral (bool) – if True, the dihedral path for a ring uses improper dihedral

Returns:

  • list[int] – path to create dihedral angles for a given atom

  • @todo (component and atom only used as component[atom] so we could maybe avoid both arguments?) – is atom an index of the atom in the component?

tqchem.batframe.bat_component(mol: tqchem.molgraph.MolecularSystem, component: list[int] = None) BATFrame

Constructor for a BATFrame with values set to None

mol: MolecularSystem

Molecular graph and ase.Atoms object

component: list[int]

atoms for which bat system will be constructed

tqchem.batframe.nitrogen_inversion(nitrogen: int, normal_torsion: dict[Dihedral, float], molecule: tqchem.molgraph.MolecularSystem) None | dict[InversionDihedral, float]

Return dihedral describing nitrogen inversion

Assuming we have the following molecule: OCN(C)CC The normal torsion is the rotation around this bond: OC-NCC We can describe nitrogen inversion by rotating the methyl group at the nitrogen atom (OC-N(C)) separately. This function returns the Torsion (i.e. {Dihedral: value}) that describes this nitrogen inversion. Note, that the inversion dihedral needs to be set before the “normal” dihedral because otherwise we would overwrite the methyl group set by the normal dihedral so that we would rotate both residues of the Nitrogen atom independently.

None is returned if the nitrogen atom is symmetrically coordinated, as for example in -NH2, or only participates in 1 or 2 bonds.