Molecule Classes#
Molsys#
- class optking.molsys.Molsys(fragments, dimer_intcos=None)[source]#
-
- Gmat(massWeight=False)[source]#
Calculates BuB^T (calculates B matrix)
- Parameters:
masses (List, optional)
- property all_fragments#
List of real (“true” moleules) and psuedo (reference atoms) fragments
- atom2frag_index(atom_index)[source]#
For a given atom in the overall molecular system return index of the fragment containing that atom
- atom_list2unique_frag_list(atomList)[source]#
Given a list of atoms, return all the fragments to which they belong
- augment_connectivity_to_single_fragment(C)[source]#
Take the current connectivity and add elements until a walk can be performed between any two atoms
- Parameters:
C (np.ndarray) – A previously determined connectivity
- Returns:
scale_dist – The scalar of covalent radii required to achieve full connectivity
- Return type:
- constraint_matrix(fq)[source]#
Returns constraint matrix with 1 on diagonal for frozen coordinates. This method used to check for forces being passed in but wasn’t being used. Forces now need to be passed in
- Parameters:
fq (np.ndarray forces)
- property dimer_psuedo_frags: List[Frag]#
List of fragments containing the reference atoms utilized in the interfragment coords
- frag_1st_atom(iF) int[source]#
Return overall index of first atom in fragment
iF, beginning 0,1,… For last fragment returns one past the end.
- frag_1st_intco(iF)[source]#
returns the index of the first internal coordinate belonging to fragment
- frag_atom_slice(iF)[source]#
Same as
frag_atom_range()but returns slice
- frag_intco_range(iF)[source]#
range of internal coordinates within the overall set corresponding to a given
Frag
- frag_intco_slice(iF)[source]#
slice of internal coordinates within the overall set corresponding to a given
Frag
- static from_psi4(mol, dtype) Tuple[Molsys, dict][source]#
Creates a optking molecular system from psi4 mol. Note that not all information is preserved. :param mol: psi4 mol :type mol: (psi4.core.Molecule, psi4.qcdb.Molecule) :param dtype: QCSchema version. Note that Molecule.schema_version is advanced by 1.
- Returns:
Molsys – optking molecular system: list of fragments
dict – qcschema representation of molecule.
- classmethod from_schema(qc_molecule: dict) Molsys[source]#
Creates optking molecular system from JSON input.
- Parameters:
qc_molecule (dict) – molecule key in MOLSSI QCSchema see http://molssi-qc-schema.readthedocs.io/en/latest/auto_topology.html
- Returns:
molsys cls consists of list of Frags
- Return type:
cls
- property frozen_intco_list#
Determine vector with 1 for any frozen internal coordinate
- property geom#
cartesian geometry [a0]
- gradient_to_cartesians(g_q)[source]#
converts the gradient from internal into Cartesian coordinates
- Parameters:
g_q (ndarray) – internal coordinate gradient
- Returns:
g_x – Cartesian coordinate gradient
- Return type:
ndarray
- gradient_to_internals(g_x, coeff=1.0, B=None, use_masses=False, threshold=1e-10)[source]#
Transform cartesian gradient to internals :param g_x: (3nat, 1) cartesian gradient :type g_x: np.ndarray :param coeff: prefactor coefficient; -1 for forces :type coeff: float :param B: B matrix to use :type B: np.ndarray, optional :param use_masses: instead of identity, use u = 1/masses in transformation :type use_masses: boolean
- Returns:
gradient in internal coordinates (coeff==1)
- Return type:
ndarray
Notes
g_q = (BuB^T)^(-1)*B*g_x
- hessian_to_internals(H, g_x=None, use_masses=False)[source]#
converts the hessian from cartesian coordinates into internal coordinates Hq = A^t (Hxy - Kxy) A, where K_xy = sum_q ( grad_q[I] d^2(q_I)/(dx dy) and A = (BuB^t)^-1 Bu
- Parameters:
H (np.ndarray) – Hessian in cartesians
g_x (np.ndarray) – (nat, 3) gradient in cartesians (optional)
massWeight (boolean) – whether to keep arbitrary transformation matrix u=I or use 1/mass_i as in spectroscopy or cases where rotations/translations matter.
- Returns:
Hq – hessian in internal coordinates
- Return type:
np.ndarray
- property masses#
array of masses for all atoms
- property num_intcos: int#
Computes total number of internal coordinates (either true internals or number of cartesians) depending on
opt_coordinates
- property num_intrafrag_intcos#
Computes number of internal coordinates but does not include coordinates in pseudo fragments
- project_redundancies_and_constraints(fq, H, threshold=1e-08)[source]#
Project redundancies and constraints out of forces and Hessian
- ranged_frozen_intco_list(fq)[source]#
Determine vector with 1 for any ranged intco that is at its limit
- split_fragments_by_connectivity(covalent_connect=1.3)[source]#
Split any fragment not connected by bond connectivity.
- test_Bmat()[source]#
Test the analytic B matrix (dq/dx) via finite differences. The 5-point formula should be good to DISP_SIZE^4 - a few unfortunates will be slightly worse.
- Returns:
passes – Returns True or False, doesn’t raise exceptions
- Return type:
boolean
Frag#
- class optking.frag.Frag(Z, geom, masses, intcos=None, frozen=False)[source]#
-
- property Z#
Getter for atomic numbers of all atoms in fragment
- add_auxiliary_bonds(connectivity=None)[source]#
Add additional bends based on increased covalent radii threshold
- add_intcos_from_connectivity(connectivity=None, ignore_coords=[])[source]#
Automatically add a set of internal coordinates to the fragment based on connectivity
- connectivity_from_distances(covalent_connect=1.3)[source]#
Determine the connectivity of the fragment based on covalent radii and distance matrix
- fix_bend_axes()[source]#
Makes sure axis defining bends does not change for all
Bendintstances in Frag’s intcos
- property frozen#
Is fragment frozen?
- property geom#
Getter for geometry (stored in [au])
- property intcos#
Getter for internal coordinates describing geometry of fragment
- property masses#
Getter for masses of all atoms in fragment [au]
- property natom#
number of atoms in frag
- property num_intcos#
Getter for number of internal coordinates in fragment
- print_intcos()[source]#
Logs a table of current values of internal coordinates in both au and angstroms
- update_dihedral_orientations()[source]#
Update orientation of each dihedrals/tors coordinate This saves an indicator if dihedral is slightly less than pi, or slighly more than -pi. Subsequently, computation of values can be greater than pi or less than -pi to enable computation of Delta(q) when q passed through pi.
DimerFrag#
- class optking.dimerfrag.DimerFrag(A_idx, A_atoms, B_idx, B_atoms, A_weights=None, B_weights=None, A_lbl='A', B_lbl='B', frozen=None)[source]#
Set of (up to 6) coordinates between two distinct fragments.
The fragments ‘A’ and ‘B’ have up to 3 reference atoms each (dA[3] and dB[3]). The reference atoms are defined in one of two ways.
If
interfrag_mode == FIXED, then fixed, linear combinations of atoms in A and B are used.- If
interfrag_mode == PRINCIPAL_AXES(NOT YET IMPLEMENTED), then the references points are the center of mass
a point a unit distance along the principal axis corresponding to the largest moment.
a point a unit distance along the principal axis corresponding to the 2nd largest moment.
- If
Notes
For simplicity, we sort the atoms in the reference point structure according to the assumed connectivity of the coordinates.
ref_geom[0] = dA[2]ref_geom[1] = dA[1]ref_geom[2] = dA[0]ref_geom[3] = dB[0]ref_geom[4] = dB[1]ref_geom[5] = dB[2]
The six coordinates, if present, formed from the
d{A-B}{0-2}sets are assumed to be the following in this canonical order:pos
sym
type
atom-definition
present, if
0
RAB
distance
dA[0]-dB[0]
always
1
theta_A
angle
dA[1]-dA[0]-dB[0]
A has > 1 atom
2
theta_B
angle
dA[0]-dB[0]-dB[1]
B has > 1 atom
3
tau
dihedral
dA[1]-dA[0]-dB[0]-dB[1]
A and B have > 1 atom
4
phi_A
dihedral
dA[2]-dA[1]-dA[0]-dB[0]
A has > 2 atoms and is not linear
5
phi_B
dihedral
dA[0]-dB[0]-dB[1]-dB[2]
B has > 2 atoms and is not linear
- Parameters:
A_idx (int) – index of fragment in molecule list
A_atoms (list of (up to 3) lists of ints) – index of atoms used to define each reference point on A
B_idx (int) – index of fragment in molecule list
B_atoms (list of (up to 3) lists of ints) – index of atoms used to define each reference point on B
(optional) (B_weights) – weights of atoms used to define each reference point of A
(optional) – weights of atoms used to define each reference point of B
A_lbl (string) – name for fragment A
B_lbl (string) – name for fragment B
confusing (The arguments are potentially)
checking. (so we'll do a lot of)
- Bmat(A_geom, B_geom, Bmat_in, A_xyz_off=None, B_xyz_off=None)[source]#
This function adds interfragment rows into an existing B matrix. B is (internals, Cartesians). Often, \(6 x 3*(Natoms)\).
- Parameters:
A_geom (numpy array) – geometry of fragment A, array is (A atoms,3)
B_geom (numpy array that is (B atoms,3)) – geometry of fragment B, array is (B atoms,3)
Bmat_int (numpy array) – provided B matrix
intco_off (int) – index of first row of Bmatrix to start writing the interfragment rows.
A_off (int) – Column of B matrix at which the cartesian coordinates of atoms in fragment A begin. Needed since columns may span full molecular system.
B_off (int) – Column of B matrix at which the cartesian coordinates of atoms in fragment B begin.
Notes
If A_off and B_off are not given, then the minimal (dimer-only) B-matrix is returned.
- classmethod from_user_dict(user_dict)[source]#
Create instance of DimerFrag from dictionary.
- Parameters:
user_dict (dict) – Dictionary representation of dimerfragment coordinates. Required keys: NATOMS PER FRAG, A_REF_ATOMS, and B_REF_ATOMS
- Raises:
ValidationError – If user_dict does not adhere to InterfragCoords Schema
- orient_fragment(Ageom_in, Bgeom_in, q_target_in, printCoords=False, unit_length='bohr', unit_angle='rad')[source]#
- orient_fragment() moves the geometry of fragment B so that the
interfragment coordinates have the given values
- Parameters:
Ageom_in (array) – Cartesian geometry of fragment A
Bgeom_in (array) – Cartesian geometry of fragment B
q_target (array float[6]) – Target values of 6 interfragment coordinates after moving fragment B
printCoords (boolean) – whether to print the starting and final values of the q’s
unit_length (string ; default 'bohr') – indicate unit of length, q[0]
unit_angle (string ; default 'rad') – indicate unit of angles, q[1-5]
------------
- Returns:
new Cartesian geometry for B
- Return type:
array