geometric/internal.py
def applyConstraints(self, xyz):
        """
        Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly.
        """
        xyz1 = xyz.copy()
        niter = 0
        xyzs = []
        ndqs = []
        while True:
            dQ = np.zeros(len(self.Internals), dtype=float)
            cDiff = -1.0 * self.calcConstraintDiff(xyz1)
            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)
                # Look up the index of the DLC that corresponds to the constraint
                iDLC = self.cDLC[ic]
                # Calculate the further change needed in this constrained variable
                dQ[iDLC] = cDiff[ic]
                dQ[iDLC] /= self.Vecs[iPrim, iDLC]
            xyzs.append(xyz1.copy())
            ndqs.append(np.linalg.norm(dQ))
            # print("applyConstraints calling newCartesian (%i), |dQ| = %.3e" % (niter, np.linalg.norm(dQ)))
            xyz2 = self.newCartesian(xyz1, dQ, verbose=0)
            if np.linalg.norm(dQ) < 1e-6:
                return xyz2
            if niter > 1 and np.linalg.norm(dQ) > np.linalg.norm(dQ0):
                xyz1 = xyzs[np.argmin(ndqs)]
                if not self.enforce_fail_printed:
                    logger.warning("Warning: Failed to enforce exact constraint satisfaction. Please remove possible redundant constraints. See below:\n")
                    self.printConstraints(xyz1, thre=0.0)
                    self.enforce_fail_printed = True
                return xyz1
            xyz1 = xyz2.copy()
            niter += 1
            dQ0 = dQ.copy()

        Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly.
        
Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly.
Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly .
def applyConstraints(self, xyz):
        xyz1 = xyz.copy()
        niter = 0
        xyzs = []
        ndqs = []
        while True:
            dQ = np.zeros(len(self.Internals), dtype=float)
            cDiff = -1.0 * self.calcConstraintDiff(xyz1)
            for ic, c in enumerate(self.Prims.cPrims):
                iPrim = self.Prims.Internals.index(c)
                iDLC = self.cDLC[ic]
                dQ[iDLC] = cDiff[ic]
                dQ[iDLC] /= self.Vecs[iPrim, iDLC]
            xyzs.append(xyz1.copy())
            ndqs.append(np.linalg.norm(dQ))
            xyz2 = self.newCartesian(xyz1, dQ, verbose=0)
            if np.linalg.norm(dQ) < 1e-6:
                return xyz2
            if niter > 1 and np.linalg.norm(dQ) > np.linalg.norm(dQ0):
                xyz1 = xyzs[np.argmin(ndqs)]
                if not self.enforce_fail_printed:
                    logger.warning("Warning: Failed to enforce exact constraint satisfaction. Please remove possible redundant constraints. See below:\n")
                    self.printConstraints(xyz1, thre=0.0)
                    self.enforce_fail_printed = True
                return xyz1
            xyz1 = xyz2.copy()
            niter += 1
            dQ0 = dQ.copy()
def applyConstraints ( self , xyz ) : xyz1 = xyz . copy ( ) niter = 0 xyzs = [ ] ndqs = [ ] while True : dQ = np . zeros ( len ( self . Internals ) , dtype = float ) cDiff = - 1.0 * self . calcConstraintDiff ( xyz1 ) for ic , c in enumerate ( self . Prims . cPrims ) : iPrim = self . Prims . Internals . index ( c ) iDLC = self . cDLC [ ic ] dQ [ iDLC ] = cDiff [ ic ] dQ [ iDLC ] /= self . Vecs [ iPrim , iDLC ] xyzs . append ( xyz1 . copy ( ) ) ndqs . append ( np . linalg . norm ( dQ ) ) xyz2 = self . newCartesian ( xyz1 , dQ , verbose = 0 ) if np . linalg . norm ( dQ ) < 1e-6 : return xyz2 if niter > 1 and np . linalg . norm ( dQ ) > np . linalg . norm ( dQ0 ) : xyz1 = xyzs [ np . argmin ( ndqs ) ] if not self . enforce_fail_printed : logger . warning ( "Warning: Failed to enforce exact constraint satisfaction. Please remove possible redundant constraints. See below:\n" ) self . printConstraints ( xyz1 , thre = 0.0 ) self . enforce_fail_printed = True return xyz1 xyz1 = xyz2 . copy ( ) niter += 1 dQ0 = dQ . copy ( )
Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly.
Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly .
"""
        Pass in Cartesian coordinates and return new coordinates that satisfy the constraints exactly.
        """ # Look up the index of the primitive that is being constrained # Look up the index of the DLC that corresponds to the constraint # Calculate the further change needed in this constrained variable # print("applyConstraints calling newCartesian (%i), |dQ| = %.3e" % (niter, np.linalg.norm(dQ)))
self
xyz