minihf.molecule.molecule module

class minihf.molecule.molecule.Molecule(atoms=None, charge=0, multiplicity=1)[source]

Bases: object

Molecule class representing a collection of atoms

classmethod build(atoms, charge=0, multiplicity=1)[source]

Build a molecule from Atom objects.

Parameters:
  • atoms (list) – A list of Atom objects.

  • charge (int, optional) – Total molecular charge (default: 0)

  • multiplicity (int, optional) – Spin multiplicity (default: 1 for singlet)

add_atom(atom)[source]

Add an atom to the molecule

remove_atom(index)[source]

Remove atom at given index

get_atom(index)[source]

Get atom at given index

bond_length(i, j)[source]

Calculate the distance between atom i and j.

Parameters:
  • i (int) – Index of first atom.

  • j (int) – Index of second atom.

Returns:

Distance between atoms i and j

Return type:

float

bond_angle(i, j, k)[source]
Calculate the bond angle between atoms i,j,k.

Where atom j is the central atom.

Parameters:
  • i (int) – Index of first atom.

  • j (int) – Index of second atom.

  • k (int) – Index of third atom.

  • unit (str, optional) – Unit of the returned angle (‘rad’ or ‘deg’, default: ‘rad’)

Returns:

Bond angle between atoms i,j,k in specified unit

Return type:

float

dihedral_angle(i, j, k, l)[source]

Calculate dihedral angle for atom connectivity A,B,C,D.

Parameters:
  • i (int) – Index of first atom (atom A).

  • j (int) – Index of second atom (atom B).

  • k (int) – Index of third atom (atom C).

  • l (int) – Index of fourth atom (atom D).

Returns:

Dihedral angle in degrees (-180 to 180)

Return type:

float

Raises:
  • TypeError – If index of atom is not int.

  • ValueError – If index of atom is not zero or positive number. If index of atom is not smaller than number of atoms.

property nelec

Number of total electrons in the molecule.

property nalpha

Number of alpha electrons in the molecule.

property nbeta

Number of beta electrons in the molecule.

property energy_nuc

Nucelar repulsion energy.

Returns:

energy – Nuclear repulsion energy.

Return type:

float

property atom_coords

Get all atomic coordinates as Nx3 array

property atom_masses

Get all atomic masses as Nx1 array

property atom_numbers

Get all atomic numbers as Nx1 array

property atom_symbols

Get all atomic symbols as Nx1 array

property mass

Get total molecular mass

property center_of_mass

Calculate the center of mass for molecular.

Returns:

[x, y, z] coordinates of center of mass

Return type:

np.ndarray