geometric/internal.py
def guess_hessian(self, coords):
        """
        Build a guess Hessian that roughly follows Schlegel's guidelines. 
        """
        xyzs = coords.reshape(-1,3)*bohr2ang
        Hdiag = []
        def covalent(a, b):
            r = np.linalg.norm(xyzs[a]-xyzs[b])
            rcov = Radii[Elements.index(self.elem[a])-1] + Radii[Elements.index(self.elem[b])-1]
            return r/rcov < 1.2
        
        for ic in self.Internals:
            if type(ic) is Distance:
                r = np.linalg.norm(xyzs[ic.a]-xyzs[ic.b]) * ang2bohr
                elem1 = min(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b]))
                elem2 = max(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b]))
                A = 1.734
                if elem1 < 3:
                    if elem2 < 3:
                        B = -0.244
                    elif elem2 < 11:
                        B = 0.352
                    else:
                        B = 0.660
                elif elem1 < 11:
                    if elem2 < 11:
                        B = 1.085
                    else:
                        B = 1.522
                else:
                    B = 2.068
                if covalent(ic.a, ic.b):
                    Hdiag.append(A/(r-B)**3)
                else:
                    Hdiag.append(0.1)
            elif type(ic) in [Angle, LinearAngle, MultiAngle]:
                if type(ic) in [Angle, LinearAngle]:
                    a = ic.a
                    c = ic.c
                else:
                    a = ic.a[-1]
                    c = ic.c[0]
                if min(Elements.index(self.elem[a]),
                       Elements.index(self.elem[ic.b]),
                       Elements.index(self.elem[c])) < 3:
                    A = 0.160
                else:
                    A = 0.250
                if covalent(a, ic.b) and covalent(ic.b, c):
                    Hdiag.append(A)
                else:
                    Hdiag.append(0.1)
            elif type(ic) in [Dihedral, MultiDihedral]:
                r = np.linalg.norm(xyzs[ic.b]-xyzs[ic.c])
                rcov = Radii[Elements.index(self.elem[ic.b])-1] + Radii[Elements.index(self.elem[ic.c])-1]
                # Hdiag.append(0.1)
                Hdiag.append(0.023)
                # The value recommended in Schlegel's paper does not appear to improve performance for larger systems.
                # Hdiag.append(max(0.0023, 0.0023-0.07*(r-rcov)))
            elif type(ic) is OutOfPlane:
                r1 = xyzs[ic.b]-xyzs[ic.a]
                r2 = xyzs[ic.c]-xyzs[ic.a]
                r3 = xyzs[ic.d]-xyzs[ic.a]
                d = 1 - np.abs(np.dot(r1,np.cross(r2,r3))/np.linalg.norm(r1)/np.linalg.norm(r2)/np.linalg.norm(r3))
                # Hdiag.append(0.1)
                if covalent(ic.a, ic.b) and covalent(ic.a, ic.c) and covalent(ic.a, ic.d):
                    Hdiag.append(0.045)
                else:
                    Hdiag.append(0.023)
            elif type(ic) in [CartesianX, CartesianY, CartesianZ]:
                Hdiag.append(0.05)
            elif type(ic) in [TranslationX, TranslationY, TranslationZ]:
                Hdiag.append(0.05)
            elif type(ic) in [RotationA, RotationB, RotationC]:
                Hdiag.append(0.05)
            else:
                raise RuntimeError('Failed to build guess Hessian matrix. Make sure all IC types are supported')
        return np.diag(Hdiag)

        Build a guess Hessian that roughly follows Schlegel's guidelines. 
        
Build a guess Hessian that roughly follows Schlegel's guidelines.
Build a guess Hessian that roughly follows Schlegel ' s guidelines .
def guess_hessian(self, coords):
        xyzs = coords.reshape(-1,3)*bohr2ang
        Hdiag = []
        def covalent(a, b):
            r = np.linalg.norm(xyzs[a]-xyzs[b])
            rcov = Radii[Elements.index(self.elem[a])-1] + Radii[Elements.index(self.elem[b])-1]
            return r/rcov < 1.2
        for ic in self.Internals:
            if type(ic) is Distance:
                r = np.linalg.norm(xyzs[ic.a]-xyzs[ic.b]) * ang2bohr
                elem1 = min(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b]))
                elem2 = max(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b]))
                A = 1.734
                if elem1 < 3:
                    if elem2 < 3:
                        B = -0.244
                    elif elem2 < 11:
                        B = 0.352
                    else:
                        B = 0.660
                elif elem1 < 11:
                    if elem2 < 11:
                        B = 1.085
                    else:
                        B = 1.522
                else:
                    B = 2.068
                if covalent(ic.a, ic.b):
                    Hdiag.append(A/(r-B)**3)
                else:
                    Hdiag.append(0.1)
            elif type(ic) in [Angle, LinearAngle, MultiAngle]:
                if type(ic) in [Angle, LinearAngle]:
                    a = ic.a
                    c = ic.c
                else:
                    a = ic.a[-1]
                    c = ic.c[0]
                if min(Elements.index(self.elem[a]),
                       Elements.index(self.elem[ic.b]),
                       Elements.index(self.elem[c])) < 3:
                    A = 0.160
                else:
                    A = 0.250
                if covalent(a, ic.b) and covalent(ic.b, c):
                    Hdiag.append(A)
                else:
                    Hdiag.append(0.1)
            elif type(ic) in [Dihedral, MultiDihedral]:
                r = np.linalg.norm(xyzs[ic.b]-xyzs[ic.c])
                rcov = Radii[Elements.index(self.elem[ic.b])-1] + Radii[Elements.index(self.elem[ic.c])-1]
                Hdiag.append(0.023)
            elif type(ic) is OutOfPlane:
                r1 = xyzs[ic.b]-xyzs[ic.a]
                r2 = xyzs[ic.c]-xyzs[ic.a]
                r3 = xyzs[ic.d]-xyzs[ic.a]
                d = 1 - np.abs(np.dot(r1,np.cross(r2,r3))/np.linalg.norm(r1)/np.linalg.norm(r2)/np.linalg.norm(r3))
                if covalent(ic.a, ic.b) and covalent(ic.a, ic.c) and covalent(ic.a, ic.d):
                    Hdiag.append(0.045)
                else:
                    Hdiag.append(0.023)
            elif type(ic) in [CartesianX, CartesianY, CartesianZ]:
                Hdiag.append(0.05)
            elif type(ic) in [TranslationX, TranslationY, TranslationZ]:
                Hdiag.append(0.05)
            elif type(ic) in [RotationA, RotationB, RotationC]:
                Hdiag.append(0.05)
            else:
                raise RuntimeError('Failed to build guess Hessian matrix. Make sure all IC types are supported')
        return np.diag(Hdiag)
def guess_hessian ( self , coords ) : xyzs = coords . reshape ( - 1 , 3 ) * bohr2ang Hdiag = [ ] def covalent ( a , b ) : r = np . linalg . norm ( xyzs [ a ] - xyzs [ b ] ) rcov = Radii [ Elements . index ( self . elem [ a ] ) - 1 ] + Radii [ Elements . index ( self . elem [ b ] ) - 1 ] return r / rcov < 1.2 for ic in self . Internals : if type ( ic ) is Distance : r = np . linalg . norm ( xyzs [ ic . a ] - xyzs [ ic . b ] ) * ang2bohr elem1 = min ( Elements . index ( self . elem [ ic . a ] ) , Elements . index ( self . elem [ ic . b ] ) ) elem2 = max ( Elements . index ( self . elem [ ic . a ] ) , Elements . index ( self . elem [ ic . b ] ) ) A = 1.734 if elem1 < 3 : if elem2 < 3 : B = - 0.244 elif elem2 < 11 : B = 0.352 else : B = 0.660 elif elem1 < 11 : if elem2 < 11 : B = 1.085 else : B = 1.522 else : B = 2.068 if covalent ( ic . a , ic . b ) : Hdiag . append ( A / ( r - B ) ** 3 ) else : Hdiag . append ( 0.1 ) elif type ( ic ) in [ Angle , LinearAngle , MultiAngle ] : if type ( ic ) in [ Angle , LinearAngle ] : a = ic . a c = ic . c else : a = ic . a [ - 1 ] c = ic . c [ 0 ] if min ( Elements . index ( self . elem [ a ] ) , Elements . index ( self . elem [ ic . b ] ) , Elements . index ( self . elem [ c ] ) ) < 3 : A = 0.160 else : A = 0.250 if covalent ( a , ic . b ) and covalent ( ic . b , c ) : Hdiag . append ( A ) else : Hdiag . append ( 0.1 ) elif type ( ic ) in [ Dihedral , MultiDihedral ] : r = np . linalg . norm ( xyzs [ ic . b ] - xyzs [ ic . c ] ) rcov = Radii [ Elements . index ( self . elem [ ic . b ] ) - 1 ] + Radii [ Elements . index ( self . elem [ ic . c ] ) - 1 ] Hdiag . append ( 0.023 ) elif type ( ic ) is OutOfPlane : r1 = xyzs [ ic . b ] - xyzs [ ic . a ] r2 = xyzs [ ic . c ] - xyzs [ ic . a ] r3 = xyzs [ ic . d ] - xyzs [ ic . a ] d = 1 - np . abs ( np . dot ( r1 , np . cross ( r2 , r3 ) ) / np . linalg . norm ( r1 ) / np . linalg . norm ( r2 ) / np . linalg . norm ( r3 ) ) if covalent ( ic . a , ic . b ) and covalent ( ic . a , ic . c ) and covalent ( ic . a , ic . d ) : Hdiag . append ( 0.045 ) else : Hdiag . append ( 0.023 ) elif type ( ic ) in [ CartesianX , CartesianY , CartesianZ ] : Hdiag . append ( 0.05 ) elif type ( ic ) in [ TranslationX , TranslationY , TranslationZ ] : Hdiag . append ( 0.05 ) elif type ( ic ) in [ RotationA , RotationB , RotationC ] : Hdiag . append ( 0.05 ) else : raise RuntimeError ( 'Failed to build guess Hessian matrix. Make sure all IC types are supported' ) return np . diag ( Hdiag )
Build a guess Hessian that roughly follows Schlegel's guidelines.
Build a guess Hessian that roughly follows Schlegel ' s guidelines .
"""
        Build a guess Hessian that roughly follows Schlegel's guidelines. 
        """ # Hdiag.append(0.1) # The value recommended in Schlegel's paper does not appear to improve performance for larger systems. # Hdiag.append(max(0.0023, 0.0023-0.07*(r-rcov))) # Hdiag.append(0.1)
self
coords