ichor.core.calculators package

Subpackages

Submodules

ichor.core.calculators.alf_features_to_coordinates_calculator module

alf_features_to_coordinates(features: ndarray) ndarray

Converts a given n_points x n_features matrix of features to cartesian coordinates of shape n_points x n_atoms x 3. Note cartesian coordinates are in Bohr as features are usually calculated in Bohr!

Parameters:

features – a numpy array of shape n_points x n_features

Note

The distances in the features are in Bohr, so the resulting Cartesian coordinates will also be in Bohr. You will need to multiply by bohr2ang (in ichor.core.constants) to convert to Cartesian coordinates in Angstroms.

ichor.core.calculators.c_matrix_calculator module

calculate_c_matrix(atom: ichor.core.atoms.Atom, alf: ichor.core.atoms.ALF) ndarray

Returns the C rotation matrix that relates the global Cartesian coordinates to the ALF Cartesian Coordinates. See https://pubs.acs.org/doi/pdf/10.1021/ct500565g , Section 3.3 for the derivations. This matrix has 3 unit vectors.

Param:

atom an instance of the Atom class: This atom is the central atom for which we want to calculate the C rotation matrix.

Parameters:

alf – An Atomic Local Frame instance for the particular atom.

Returns:

A 3x3 numpy array which is the C rotation matrix.

ichor.core.calculators.geometry_calculator module

angle_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the angle names for atoms

Parameters:

atoms – ‘Atoms’ instance to get the angle names

Returns:

angle names of atoms as list of str

angles(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int, int]]
bond_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the bond names for atoms :param atoms: ‘Atoms’ instance to get the bond names :return: bond names of atoms as list of str

bonds(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int]]
calculate_angle(atoms: ichor.core.atoms.Atoms, i: int, j: int, k: int)

Calculates the angle between atoms i, j, and k for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate angle

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

  • k – 0-index atoms[k]

Returns:

angle between atoms i-j-k as float

calculate_angles(atoms: ichor.core.atoms.Atoms) ndarray
calculate_bond(atoms: ichor.core.atoms.Atoms, i: int, j: int)

Calculates the bond distance between atoms i and j for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate bond distance

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

Returns:

bond distance between atoms i-j as float

calculate_bonds(atoms: ichor.core.atoms.Atoms) ndarray
calculate_dihedral(atoms: ichor.core.atoms.Atoms, i: int, j: int, k: int, l: int) float

Calculates the dihedral angle between atoms i, j, k and l for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate dihedral angle

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

  • k – 0-index atoms[k]

  • l – 0-index atoms[l]

Returns:

dihedral angle between atoms i-j-k-l as float

calculate_dihedrals(atoms: ichor.core.atoms.Atoms) ndarray
calculate_internal_features(atoms: ichor.core.atoms.Atoms) Tuple[ndarray, ndarray, ndarray]

Calculates the bonds, angles and dihedrals for atoms

Parameters:

atoms – instance of Atoms to calculate the bonds, angles and dihedrals for

Returns:

bonds, angles and dihedrals as a tuple of numpy arrays

dihedral_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the dihedral names for atoms

Parameters:

atoms – ‘Atoms’ instance to get the dihedral names

Returns:

dihedral names of atoms as list of str

dihedrals(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int, int, int]]
get_connected_atoms(atoms: ichor.core.atoms.Atoms) ichor.core.files.dl_poly.dl_poly_field.ConnectedAtoms
get_internal_feature_indices(atoms: ichor.core.atoms.Atoms) Tuple[List[Tuple[int, int]], List[Tuple[int, int, int]], List[Tuple[int, int, int, int]]]
internal_feature_names(atoms: ichor.core.atoms.Atoms) Tuple[List[str], List[str], List[str]]

Gets the names of the bonds, angles and dihedrals for atoms

Parameters:

atoms – instance of ‘Atoms’ to get the names for bonds, angles and dihedrals

Returns:

tuple of lists of the names for the bonds angles and dihedrals for atoms

ichor.core.calculators.spherical_to_cartesian_calculator module

spherical_to_cartesian(r, theta, phi) List[float]

Spherical to cartesian transformation

\[ \begin{align}\begin{aligned}r \in [0, \inf) \theta in [0, \pi] \phi in [-\pi, \pi)\\x = r sin \theta cos\phi y = r sin \phi sin\theta z = r cos\theta\end{aligned}\end{align} \]

Module contents

alf_features_to_coordinates(features: ndarray) ndarray

Converts a given n_points x n_features matrix of features to cartesian coordinates of shape n_points x n_atoms x 3. Note cartesian coordinates are in Bohr as features are usually calculated in Bohr!

Parameters:

features – a numpy array of shape n_points x n_features

Note

The distances in the features are in Bohr, so the resulting Cartesian coordinates will also be in Bohr. You will need to multiply by bohr2ang (in ichor.core.constants) to convert to Cartesian coordinates in Angstroms.

angle_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the angle names for atoms

Parameters:

atoms – ‘Atoms’ instance to get the angle names

Returns:

angle names of atoms as list of str

angles(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int, int]]
bond_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the bond names for atoms :param atoms: ‘Atoms’ instance to get the bond names :return: bond names of atoms as list of str

bonds(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int]]
calculate_alf_atom_sequence(atom: ichor.core.atoms.Atom) ichor.core.atoms.ALF
calculate_alf_cahn_ingold_prelog(atom: ichor.core.atoms.Atom, connectivity_calculator=<function connectivity_calculator_valence>) ichor.core.atoms.ALF
calculate_alf_features(atom: ichor.core.atoms.Atom, alf: ichor.core.atoms.ALF | List[ichor.core.atoms.ALF] | List[List[int]] | Dict[str, ichor.core.atoms.ALF], distance_unit: AtomicDistance = AtomicDistance.Bohr) ndarray

Calculates the features for the given central atom.

:paramparam atom: an instance of the Atom class:

This atom is the central atom for which we want to calculate the C rotation matrix.

:paramparam alf: A callable or instance of ALF that is used to

calculate the atomic local frame for the atom. This atomic local frame then defines the features which are going to be calculated. If no ALF is passed by user, then the default way of calculating ALF is used.

:paramparam distance_unit: The distance units to use for the calculated distances

which are part of the features. The default distance is Bohr.

Returns:

type: np.ndarray

A 1D numpy array of shape 3N-6, where N is the number of atoms in the system which atom is a part of. If there are only two atoms, then there is only 1 feature (the distance between the atoms).

calculate_angle(atoms: ichor.core.atoms.Atoms, i: int, j: int, k: int)

Calculates the angle between atoms i, j, and k for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate angle

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

  • k – 0-index atoms[k]

Returns:

angle between atoms i-j-k as float

calculate_bond(atoms: ichor.core.atoms.Atoms, i: int, j: int)

Calculates the bond distance between atoms i and j for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate bond distance

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

Returns:

bond distance between atoms i-j as float

calculate_c_matrix(atom: ichor.core.atoms.Atom, alf: ichor.core.atoms.ALF) ndarray

Returns the C rotation matrix that relates the global Cartesian coordinates to the ALF Cartesian Coordinates. See https://pubs.acs.org/doi/pdf/10.1021/ct500565g , Section 3.3 for the derivations. This matrix has 3 unit vectors.

Param:

atom an instance of the Atom class: This atom is the central atom for which we want to calculate the C rotation matrix.

Parameters:

alf – An Atomic Local Frame instance for the particular atom.

Returns:

A 3x3 numpy array which is the C rotation matrix.

calculate_dihedral(atoms: ichor.core.atoms.Atoms, i: int, j: int, k: int, l: int) float

Calculates the dihedral angle between atoms i, j, k and l for atoms.

Parameters:
  • atoms – instance of ‘Atoms’ to calculate dihedral angle

  • i – 0-index atoms[i]

  • j – 0-index atoms[j]

  • k – 0-index atoms[k]

  • l – 0-index atoms[l]

Returns:

dihedral angle between atoms i-j-k-l as float

calculate_internal_features(atoms: ichor.core.atoms.Atoms) Tuple[ndarray, ndarray, ndarray]

Calculates the bonds, angles and dihedrals for atoms

Parameters:

atoms – instance of Atoms to calculate the bonds, angles and dihedrals for

Returns:

bonds, angles and dihedrals as a tuple of numpy arrays

default_alf_calculator(atom: ichor.core.atoms.Atom) ichor.core.atoms.ALF
default_connectivity_calculator(atoms: ichor.core.atoms.Atoms) ndarray

Calculates the connectivity matrix (showing which atoms are bonded as 1 and those that are not bonded as 0. It uses the Van Der Waals radius an Atom (see Atom class) to determine if atoms should be bonded or not.

:param : atoms: Atoms instance

Returns:

type: np.ndarray

The connectivity matrix between atoms of shape len(atoms) x len(atoms)

Note

This is a class method because the connectivity only needs to be calculated once per trajectory. The connectivity remains the same for all timesteps in a trajectory.

default_feature_calculator(atom: ichor.core.atoms.Atom, alf: ichor.core.atoms.ALF | List[ichor.core.atoms.ALF] | List[List[int]] | Dict[str, ichor.core.atoms.ALF], distance_unit: AtomicDistance = AtomicDistance.Bohr) ndarray

Calculates the features for the given central atom.

:paramparam atom: an instance of the Atom class:

This atom is the central atom for which we want to calculate the C rotation matrix.

:paramparam alf: A callable or instance of ALF that is used to

calculate the atomic local frame for the atom. This atomic local frame then defines the features which are going to be calculated. If no ALF is passed by user, then the default way of calculating ALF is used.

:paramparam distance_unit: The distance units to use for the calculated distances

which are part of the features. The default distance is Bohr.

Returns:

type: np.ndarray

A 1D numpy array of shape 3N-6, where N is the number of atoms in the system which atom is a part of. If there are only two atoms, then there is only 1 feature (the distance between the atoms).

dihedral_names(atoms: ichor.core.atoms.Atoms) List[str]

Returns the dihedral names for atoms

Parameters:

atoms – ‘Atoms’ instance to get the dihedral names

Returns:

dihedral names of atoms as list of str

dihedrals(atoms: ichor.core.atoms.Atoms) List[Tuple[int, int, int, int]]
get_atom_alf(atom: ichor.core.atoms.Atom, alf: ichor.core.atoms.ALF | List[ichor.core.atoms.ALF] | Dict[str, ichor.core.atoms.ALF])
get_internal_feature_indices(atoms: ichor.core.atoms.Atoms) Tuple[List[Tuple[int, int]], List[Tuple[int, int, int]], List[Tuple[int, int, int, int]]]
internal_feature_names(atoms: ichor.core.atoms.Atoms) Tuple[List[str], List[str], List[str]]

Gets the names of the bonds, angles and dihedrals for atoms

Parameters:

atoms – instance of ‘Atoms’ to get the names for bonds, angles and dihedrals

Returns:

tuple of lists of the names for the bonds angles and dihedrals for atoms

spherical_to_cartesian(r, theta, phi) List[float]

Spherical to cartesian transformation

\[ \begin{align}\begin{aligned}r \in [0, \inf) \theta in [0, \pi] \phi in [-\pi, \pi)\\x = r sin \theta cos\phi y = r sin \phi sin\theta z = r cos\theta\end{aligned}\end{align} \]