Molecule (qcip_tools.molecule
)
API documentation
- class qcip_tools.molecule.Bond(atom_1, atom_2, bond_type='single', indexes=None)
Define a bond between two atoms
- exception qcip_tools.molecule.GroupError
- exception qcip_tools.molecule.MolecularSymmetryError
- class qcip_tools.molecule.MolecularSymmetryFinder(molecule, with_='Z', randomise_dummy=True, tol=1e-05)
High-level symmetry finder on the molecule
- Parameters:
molecule (Molecule) – the molecule
with (str) – used to differentiate atoms
randomise_dummy (bool) – randomise dummy atoms so that they are all different
tol (float) – tolerance
- orient_molecule()
Find the symmetry of the molecule, then orient it (just translation, then rotation).
- Return type:
- symmetrise_molecule(lowers_infinite=-1)
After
`orient_molecule()
, and among the unique positionsFind the set of unique atoms: apply the symmetry elements and groups atoms together ;
Compute an average position by using the inverse of the symmetry elements on the position of the first atom ;
Set components that are almost zero (wrt
self.tol
) to zero ;Generate back the other positions using the symmetry elements on the average position.
Warning
It needs to generate all the group elements first, so that may take time ;
This will therefore slightly change the geometry by moving the atoms.
- Returns:
the point group and a list of uniques atoms indexes
- Return type:
- class qcip_tools.molecule.Molecule(atom_list=None, charge=0)
Class to define a molecule (basically a list of atoms).
This object is mutable.
Note
Each time a function requires a
shifted_index
, indexing starts at 1 instead of 0.- MO_to_str(mo_level)
Get the corresponding Molecular Orbital (MO) as HOMO-x/LUMO+x.
Note
Assume closed-shell.
- Parameters:
mo_level (int) – MO number (starting at 1)
- Return type:
str
- atom(shifted_index)
Get the atom defined by index
- Parameters:
shifted_index (int) – Index of the atom in the list
- Return type:
qcip_atom.Atom
- atoms(**kwargs)
Get a list of atom (index) based on some criterion
- bonds(threshold=0.1)
Get a list of the bond in the molecule.
- Parameters:
threshold (float) – threshold (see
self. connectivites()
)- Return type:
list
- bounding_box(extra_space=0.0)
Get the bounding box corresponding to the molecule.
- Parameters:
extra_space (float) – Add some space around the box
- Returns:
Bounding box
- Return type:
- center_of_charges()
Position of the center of charge
- Return type:
numpy.ndarray
- center_of_mass()
Position of the center of mass
- Return type:
numpy.ndarray
- connectivities(threshold=0.1)
Get connectivity atom by atom, using the VdW radii.
- Parameters:
threshold (float) – threshold for acceptance (because bond are sometimes a little larger than the sum of VdWs)
- Returns:
the connectivity, as a dictionary per atom index (as shifted_indexes)
- Return type:
dict
- distances()
Retrieve the distance matrix between all atoms in the molecule.
Note
The array indexes are NOT shifted indexes.
- Return type:
numpy.ndarray
- formula(enhanced=False)
Get the formula, based on self.formula_holder and self. symbols_contained. Implementation note : logically, it can write the atoms in whatever order. But in chemistry, the usual way is to start in this order C,H,N,O,X … Where X is the other(s) atom(s). So does this. “enhanced” use “X_{i}” to indicate indice i instead of just “Xi”.
- insert(atom, position=None)
Add atom in the list.
- Parameters:
atom (qcip_tools.atom.Atom|int|str) – an atom (raise Exception if it’s not the case)
position (int) – position in the list.
- linear(threshold=1e-05)
Compute if the molecule is linear or not. A molecule is linear if \(I_\alpha \approx 0\) and \(I_\beta \approx I_\gamma\), if \(I_\alpha < I_\beta \approx I_\gamma\).
- Parameters:
threshold (float) – threshold for the moment of inertia
- Return type:
bool
- list_of_atoms(shifted_index, exclude_atoms=None)
Make a list of atoms following the connectivity and excluding some if any.
- Parameters:
shifted_index (int) – starting atom
exclude_atoms (list of int) – stop following atom (listed as shifted_indexes) if on one of those
- Returns:
list of atoms (as shifted_indexes)
- Return type:
list of int
- mass()
Get the mass of the molecule
- Return type:
float
- moments_of_inertia()
Get the moment of inertia tensor.
- Return type:
numpy.ndarray
- number_of_electrons()
- Returns:
The number of electrons in the molecule
- output_atoms(use_z_instead_of_symbol=False)
List atoms.
- Parameters:
use_z_instead_of_symbol (bool) – put atomic number instead of symbol
- Returns:
formatted string <symbol or number> <x> <y> <z>
- Return type:
str
- position_matrix(with_='Z', randomise_dummy=True)
Get position matrix
- Parameters:
with (str) – extra first column, either
Z
,masss
orcharge
randomise_dummy (bool) – use a random number, outside of range, for dummy atoms
- Return type:
numpy.ndarray
- principal_axes()
Return the moment of inertia (from https://github.com/moorepants/DynamicistToolKit/blob/master/dtk/inertia.py).
- Returns:
The principal moment of inertia (sorted from lowest to largest) and the rotation matrix
- Return type:
tuple
- remove_atom(shifted_index)
Remove an atom in the list :param shifted_index: index of the atom
- set_to_inertia_axes()
Translate and rotate molecule to its principal inertia axes
- square_of_spin_angular_moment()
Return \(\hat{S}_z^2=S\,(S+1)\), where \(S\) is the spin value
- Return type:
float
- translate_self_to_center_of_charges()
Translate the molecule to the center of charge
- translate_self_to_center_of_mass()
Translate the molecule to the center of mass
- exception qcip_tools.molecule.ShiftedIndexError(val, mol)
- qcip_tools.molecule.gen_molecule_from_unique_atoms(unique_atoms, group, tol=0.001)
Generate a molecule out of the uniques atoms and the symmetry group
- Parameters:
unique_atoms (list) – set of unique atoms (please use unique ones !!)
group (qcip_tools.symmetry.PointGroup) – point group
- Return type: