geometric/internal.py
def build_dlc_0(self, xyz):
        """
        Build the delocalized internal coordinates (DLCs) which are linear 
        combinations of the primitive internal coordinates. Each DLC is stored
        as a column in self.Vecs.
        
        In short, each DLC is an eigenvector of the G-matrix, and the number of
        nonzero eigenvalues of G should be equal to 3*N. 
        
        After creating the DLCs, we construct special ones corresponding to primitive
        coordinates that are constrained (cProj).  These are placed in the front (i.e. left)
        of the list of DLCs, and then we perform a Gram-Schmidt orthogonalization.

        This function is called at the end of __init__ after the coordinate system is already
        specified (including which primitives are constraints).

        Parameters
        ----------
        xyz : np.ndarray
            Flat array containing Cartesian coordinates in atomic units
        """
        # Perform singular value decomposition
        click()
        G = self.Prims.GMatrix(xyz)
        # Manipulate G-Matrix to increase weight of constrained coordinates
        if self.haveConstraints():
            for ic, c in enumerate(self.Prims.cPrims):
                iPrim = self.Prims.Internals.index(c)
                G[:, iPrim] *= 1.0
                G[iPrim, :] *= 1.0
        ncon = len(self.Prims.cPrims)
        # Water Dimer: 100.0, no check -> -151.1892668451
        time_G = click()
        L, Q = np.linalg.eigh(G)
        time_eig = click()
        # print "Build G: %.3f Eig: %.3f" % (time_G, time_eig)
        LargeVals = 0
        LargeIdx = []
        for ival, value in enumerate(L):
            # print ival, value
            if np.abs(value) > 1e-6:
                LargeVals += 1
                LargeIdx.append(ival)
        Expect = 3*self.na
        # print "%i atoms (expect %i coordinates); %i/%i singular values are > 1e-6" % (self.na, Expect, LargeVals, len(L))
        # if LargeVals <= Expect:
        self.Vecs = Q[:, LargeIdx]

        # Vecs has number of rows equal to the number of primitives, and
        # number of columns equal to the number of delocalized internal coordinates.
        if self.haveConstraints():
            click()
            # print "Projecting out constraints...",
            V = []
            for ic, c in enumerate(self.Prims.cPrims):
                # Look up the index of the primitive that is being constrained
                iPrim = self.Prims.Internals.index(c)
                # Pick a row out of the eigenvector space. This is a linear combination of the DLCs.
                cVec = self.Vecs[iPrim, :]
                cVec = np.array(cVec)
                cVec /= np.linalg.norm(cVec)
                # This is a "new DLC" that corresponds to the primitive that we are constraining
                cProj = np.dot(self.Vecs,cVec.T)
                cProj /= np.linalg.norm(cProj)
                V.append(np.array(cProj).flatten())
                # print c, cProj[iPrim]
            # V contains the constraint vectors on the left, and the original DLCs on the right
            V = np.hstack((np.array(V).T, np.array(self.Vecs)))
            # Apply Gram-Schmidt to V, and produce U.
            # The Gram-Schmidt process should produce a number of orthogonal DLCs equal to the original number
            thre = 1e-6
            while True:
                U = []
                for iv in range(V.shape[1]):
                    v = V[:, iv].flatten()
                    U.append(v.copy())
                    for ui in U[:-1]:
                        U[-1] -= ui * np.dot(ui, v)
                    if np.linalg.norm(U[-1]) < thre:
                        U = U[:-1]
                        continue
                    U[-1] /= np.linalg.norm(U[-1])
                if len(U) > self.Vecs.shape[1]:
                    thre *= 10
                elif len(U) == self.Vecs.shape[1]:
                    break
                elif len(U) < self.Vecs.shape[1]:
                    raise RuntimeError('Gram-Schmidt orthogonalization has failed (expect %i length %i)' % (self.Vecs.shape[1], len(U)))
            # print "Gram-Schmidt completed with thre=%.0e" % thre
            self.Vecs = np.array(U).T
            # Constrained DLCs are on the left of self.Vecs.
            self.cDLC = [i for i in range(len(self.Prims.cPrims))]
        # Now self.Internals is no longer a list of InternalCoordinate objects but only a list of strings.
        # We do not create objects for individual DLCs but 
        self.Internals = ["Constraint-DLC" if i < ncon else "DLC" + " %i" % (i+1) for i in range(self.Vecs.shape[1])]

        Build the delocalized internal coordinates (DLCs) which are linear 
        combinations of the primitive internal coordinates. Each DLC is stored
        as a column in self.Vecs.
        
        In short, each DLC is an eigenvector of the G-matrix, and the number of
        nonzero eigenvalues of G should be equal to 3*N. 
        
        After creating the DLCs, we construct special ones corresponding to primitive
        coordinates that are constrained (cProj).  These are placed in the front (i.e. left)
        of the list of DLCs, and then we perform a Gram-Schmidt orthogonalization.

        This function is called at the end of __init__ after the coordinate system is already
        specified (including which primitives are constraints).

        Parameters
        ----------
        xyz : np.ndarray
            Flat array containing Cartesian coordinates in atomic units
        
Build the delocalized internal coordinates (DLCs) which are linear
combinations of the primitive internal coordinates. Each DLC is stored
as a column in self.Vecs.

In short, each DLC is an eigenvector of the G-matrix, and the number of
nonzero eigenvalues of G should be equal to 3*N.

After creating the DLCs, we construct special ones corresponding to primitive
coordinates that are constrained (cProj).  These are placed in the front
of the list of DLCs, and then we perform a Gram-Schmidt orthogonalization.

This function is called at the end of __init__ after the coordinate system is already
specified (including which primitives are constraints).

Parameters

xyz : np.ndarray
Flat array containing Cartesian coordinates in atomic units
Build the delocalized internal coordinates ( DLCs ) which are linear combinations of the primitive internal coordinates . Each DLC is stored as a column in self . Vecs . In short each DLC is an eigenvector of the G - matrix and the number of nonzero eigenvalues of G should be equal to 3 * N . After creating the DLCs we construct special ones corresponding to primitive coordinates that are constrained ( cProj ) . These are placed in the front of the list of DLCs and then we perform a Gram - Schmidt orthogonalization . This function is called at the end of __init__ after the coordinate system is already specified ( including which primitives are constraints ) . Parameters xyz : np . ndarray Flat array containing Cartesian coordinates in atomic units
def build_dlc_0(self, xyz):
        click()
        G = self.Prims.GMatrix(xyz)
        if self.haveConstraints():
            for ic, c in enumerate(self.Prims.cPrims):
                iPrim = self.Prims.Internals.index(c)
                G[:, iPrim] *= 1.0
                G[iPrim, :] *= 1.0
        ncon = len(self.Prims.cPrims)
        time_G = click()
        L, Q = np.linalg.eigh(G)
        time_eig = click()
        LargeVals = 0
        LargeIdx = []
        for ival, value in enumerate(L):
            if np.abs(value) > 1e-6:
                LargeVals += 1
                LargeIdx.append(ival)
        Expect = 3*self.na
        self.Vecs = Q[:, LargeIdx]
        if self.haveConstraints():
            click()
            V = []
            for ic, c in enumerate(self.Prims.cPrims):
                iPrim = self.Prims.Internals.index(c)
                cVec = self.Vecs[iPrim, :]
                cVec = np.array(cVec)
                cVec /= np.linalg.norm(cVec)
                cProj = np.dot(self.Vecs,cVec.T)
                cProj /= np.linalg.norm(cProj)
                V.append(np.array(cProj).flatten())
            V = np.hstack((np.array(V).T, np.array(self.Vecs)))
            thre = 1e-6
            while True:
                U = []
                for iv in range(V.shape[1]):
                    v = V[:, iv].flatten()
                    U.append(v.copy())
                    for ui in U[:-1]:
                        U[-1] -= ui * np.dot(ui, v)
                    if np.linalg.norm(U[-1]) < thre:
                        U = U[:-1]
                        continue
                    U[-1] /= np.linalg.norm(U[-1])
                if len(U) > self.Vecs.shape[1]:
                    thre *= 10
                elif len(U) == self.Vecs.shape[1]:
                    break
                elif len(U) < self.Vecs.shape[1]:
                    raise RuntimeError('Gram-Schmidt orthogonalization has failed (expect %i length %i)' % (self.Vecs.shape[1], len(U)))
            self.Vecs = np.array(U).T
            self.cDLC = [i for i in range(len(self.Prims.cPrims))]
        self.Internals = ["Constraint-DLC" if i < ncon else "DLC" + " %i" % (i+1) for i in range(self.Vecs.shape[1])]
def build_dlc_0 ( self , xyz ) : click ( ) G = self . Prims . GMatrix ( xyz ) if self . haveConstraints ( ) : for ic , c in enumerate ( self . Prims . cPrims ) : iPrim = self . Prims . Internals . index ( c ) G [ : , iPrim ] *= 1.0 G [ iPrim , : ] *= 1.0 ncon = len ( self . Prims . cPrims ) time_G = click ( ) L , Q = np . linalg . eigh ( G ) time_eig = click ( ) LargeVals = 0 LargeIdx = [ ] for ival , value in enumerate ( L ) : if np . abs ( value ) > 1e-6 : LargeVals += 1 LargeIdx . append ( ival ) Expect = 3 * self . na self . Vecs = Q [ : , LargeIdx ] if self . haveConstraints ( ) : click ( ) V = [ ] for ic , c in enumerate ( self . Prims . cPrims ) : iPrim = self . Prims . Internals . index ( c ) cVec = self . Vecs [ iPrim , : ] cVec = np . array ( cVec ) cVec /= np . linalg . norm ( cVec ) cProj = np . dot ( self . Vecs , cVec . T ) cProj /= np . linalg . norm ( cProj ) V . append ( np . array ( cProj ) . flatten ( ) ) V = np . hstack ( ( np . array ( V ) . T , np . array ( self . Vecs ) ) ) thre = 1e-6 while True : U = [ ] for iv in range ( V . shape [ 1 ] ) : v = V [ : , iv ] . flatten ( ) U . append ( v . copy ( ) ) for ui in U [ : - 1 ] : U [ - 1 ] -= ui * np . dot ( ui , v ) if np . linalg . norm ( U [ - 1 ] ) < thre : U = U [ : - 1 ] continue U [ - 1 ] /= np . linalg . norm ( U [ - 1 ] ) if len ( U ) > self . Vecs . shape [ 1 ] : thre *= 10 elif len ( U ) == self . Vecs . shape [ 1 ] : break elif len ( U ) < self . Vecs . shape [ 1 ] : raise RuntimeError ( 'Gram-Schmidt orthogonalization has failed (expect %i length %i)' % ( self . Vecs . shape [ 1 ] , len ( U ) ) ) self . Vecs = np . array ( U ) . T self . cDLC = [ i for i in range ( len ( self . Prims . cPrims ) ) ] self . Internals = [ "Constraint-DLC" if i < ncon else "DLC" + " %i" % ( i + 1 ) for i in range ( self . Vecs . shape [ 1 ] ) ]
Build the delocalized internal coordinates (DLCs) which are linear
combinations of the primitive internal coordinates.
Build the delocalized internal coordinates ( DLCs ) which are linear combinations of the primitive internal coordinates .
"""
        Build the delocalized internal coordinates (DLCs) which are linear 
        combinations of the primitive internal coordinates. Each DLC is stored
        as a column in self.Vecs.
        
        In short, each DLC is an eigenvector of the G-matrix, and the number of
        nonzero eigenvalues of G should be equal to 3*N. 
        
        After creating the DLCs, we construct special ones corresponding to primitive
        coordinates that are constrained (cProj).  These are placed in the front (i.e. left)
        of the list of DLCs, and then we perform a Gram-Schmidt orthogonalization.

        This function is called at the end of __init__ after the coordinate system is already
        specified (including which primitives are constraints).

        Parameters
        ----------
        xyz : np.ndarray
            Flat array containing Cartesian coordinates in atomic units
        """ # Perform singular value decomposition # Manipulate G-Matrix to increase weight of constrained coordinates # Water Dimer: 100.0, no check -> -151.1892668451 # print "Build G: %.3f Eig: %.3f" % (time_G, time_eig) # print ival, value # print "%i atoms (expect %i coordinates); %i/%i singular values are > 1e-6" % (self.na, Expect, LargeVals, len(L)) # if LargeVals <= Expect: # Vecs has number of rows equal to the number of primitives, and # number of columns equal to the number of delocalized internal coordinates. # print "Projecting out constraints...", # Look up the index of the primitive that is being constrained # Pick a row out of the eigenvector space. This is a linear combination of the DLCs. # This is a "new DLC" that corresponds to the primitive that we are constraining # print c, cProj[iPrim] # V contains the constraint vectors on the left, and the original DLCs on the right # Apply Gram-Schmidt to V, and produce U. # The Gram-Schmidt process should produce a number of orthogonal DLCs equal to the original number # print "Gram-Schmidt completed with thre=%.0e" % thre # Constrained DLCs are on the left of self.Vecs. # Now self.Internals is no longer a list of InternalCoordinate objects but only a list of strings. # We do not create objects for individual DLCs but 
self
xyz