geometric/step.py
def rebuild_hessian(IC, H0, coord_seq, grad_seq, params):
    """
    Rebuild the Hessian after making a change to the internal coordinate system.

    Parameters
    ----------
    IC : InternalCoordinates
        Object describing the internal coordinate system
    H0 : np.ndarray
        N_ic x N_ic square matrix containing the guess Hessian
    coord_seq : list
        List of N_atom x 3 Cartesian coordinates in atomic units
    grad_seq : list
        List of N_atom x 3 Cartesian gradients in atomic units
    params : OptParams object
        Uses trust, epsilon, and reset
        trust : Only recover using previous geometries within the trust radius
        epsilon : Small eigenvalue threshold
        reset : Revert to the guess Hessian if eigenvalues smaller than threshold

    Returns
    -------
    np.ndarray
        Internal coordinate Hessian updated with series of internal coordinate gradients
    """
    Na = len(coord_seq[0])/3
    history = 0
    for i in range(2, len(coord_seq)+1):
        disp = bohr2ang*(coord_seq[-i]-coord_seq[-1])
        rmsd = np.sqrt(np.sum(disp**2)/Na)
        if rmsd > params.trust: break
        history += 1
    if history < 1:
        return H0.copy()
    logger.info("Rebuilding Hessian using %i gradients\n" % history)
    y_seq = [IC.calculate(i) for i in coord_seq[-history-1:]]
    g_seq = [IC.calcGrad(i, j) for i, j in zip(coord_seq[-history-1:],grad_seq[-history-1:])]
    Yprev = y_seq[0]
    Gprev = g_seq[0]
    H = H0.copy()
    for i in range(1, len(y_seq)):
        Y = y_seq[i]
        G = g_seq[i]
        Yprev = y_seq[i-1]
        Gprev = g_seq[i-1]
        Dy   = col(Y - Yprev)
        Dg   = col(G - Gprev)
        # Mat1 = (Dg*Dg.T)/(Dg.T*Dy)[0,0]
        # Mat2 = ((H*Dy)*(H*Dy).T)/(Dy.T*H*Dy)[0,0]
        Mat1 = np.dot(Dg,Dg.T)/np.dot(Dg.T,Dy)[0,0]
        Mat2 = np.dot(np.dot(H,Dy),np.dot(H,Dy).T)/multi_dot([Dy.T,H,Dy])[0,0]
        Hstor = H.copy()
        H += Mat1-Mat2
    if np.min(np.linalg.eigh(H)[0]) < params.epsilon and params.reset:
        logger.info("Eigenvalues below %.4e (%.4e) - returning guess\n" % (params.epsilon, np.min(np.linalg.eigh(H)[0])))
        return H0.copy()
    return H

    Rebuild the Hessian after making a change to the internal coordinate system.

    Parameters
    ----------
    IC : InternalCoordinates
        Object describing the internal coordinate system
    H0 : np.ndarray
        N_ic x N_ic square matrix containing the guess Hessian
    coord_seq : list
        List of N_atom x 3 Cartesian coordinates in atomic units
    grad_seq : list
        List of N_atom x 3 Cartesian gradients in atomic units
    params : OptParams object
        Uses trust, epsilon, and reset
        trust : Only recover using previous geometries within the trust radius
        epsilon : Small eigenvalue threshold
        reset : Revert to the guess Hessian if eigenvalues smaller than threshold

    Returns
    -------
    np.ndarray
        Internal coordinate Hessian updated with series of internal coordinate gradients
    
Rebuild the Hessian after making a change to the internal coordinate system.
Parameters



Returns

np.ndarray
Internal coordinate Hessian updated with series of internal coordinate gradients
Rebuild the Hessian after making a change to the internal coordinate system . Parameters Returns np . ndarray Internal coordinate Hessian updated with series of internal coordinate gradients
def rebuild_hessian(IC, H0, coord_seq, grad_seq, params):
    Na = len(coord_seq[0])/3
    history = 0
    for i in range(2, len(coord_seq)+1):
        disp = bohr2ang*(coord_seq[-i]-coord_seq[-1])
        rmsd = np.sqrt(np.sum(disp**2)/Na)
        if rmsd > params.trust: break
        history += 1
    if history < 1:
        return H0.copy()
    logger.info("Rebuilding Hessian using %i gradients\n" % history)
    y_seq = [IC.calculate(i) for i in coord_seq[-history-1:]]
    g_seq = [IC.calcGrad(i, j) for i, j in zip(coord_seq[-history-1:],grad_seq[-history-1:])]
    Yprev = y_seq[0]
    Gprev = g_seq[0]
    H = H0.copy()
    for i in range(1, len(y_seq)):
        Y = y_seq[i]
        G = g_seq[i]
        Yprev = y_seq[i-1]
        Gprev = g_seq[i-1]
        Dy   = col(Y - Yprev)
        Dg   = col(G - Gprev)
        Mat1 = np.dot(Dg,Dg.T)/np.dot(Dg.T,Dy)[0,0]
        Mat2 = np.dot(np.dot(H,Dy),np.dot(H,Dy).T)/multi_dot([Dy.T,H,Dy])[0,0]
        Hstor = H.copy()
        H += Mat1-Mat2
    if np.min(np.linalg.eigh(H)[0]) < params.epsilon and params.reset:
        logger.info("Eigenvalues below %.4e (%.4e) - returning guess\n" % (params.epsilon, np.min(np.linalg.eigh(H)[0])))
        return H0.copy()
    return H
def rebuild_hessian ( IC , H0 , coord_seq , grad_seq , params ) : Na = len ( coord_seq [ 0 ] ) / 3 history = 0 for i in range ( 2 , len ( coord_seq ) + 1 ) : disp = bohr2ang * ( coord_seq [ - i ] - coord_seq [ - 1 ] ) rmsd = np . sqrt ( np . sum ( disp ** 2 ) / Na ) if rmsd > params . trust : break history += 1 if history < 1 : return H0 . copy ( ) logger . info ( "Rebuilding Hessian using %i gradients\n" % history ) y_seq = [ IC . calculate ( i ) for i in coord_seq [ - history - 1 : ] ] g_seq = [ IC . calcGrad ( i , j ) for i , j in zip ( coord_seq [ - history - 1 : ] , grad_seq [ - history - 1 : ] ) ] Yprev = y_seq [ 0 ] Gprev = g_seq [ 0 ] H = H0 . copy ( ) for i in range ( 1 , len ( y_seq ) ) : Y = y_seq [ i ] G = g_seq [ i ] Yprev = y_seq [ i - 1 ] Gprev = g_seq [ i - 1 ] Dy = col ( Y - Yprev ) Dg = col ( G - Gprev ) Mat1 = np . dot ( Dg , Dg . T ) / np . dot ( Dg . T , Dy ) [ 0 , 0 ] Mat2 = np . dot ( np . dot ( H , Dy ) , np . dot ( H , Dy ) . T ) / multi_dot ( [ Dy . T , H , Dy ] ) [ 0 , 0 ] Hstor = H . copy ( ) H += Mat1 - Mat2 if np . min ( np . linalg . eigh ( H ) [ 0 ] ) < params . epsilon and params . reset : logger . info ( "Eigenvalues below %.4e (%.4e) - returning guess\n" % ( params . epsilon , np . min ( np . linalg . eigh ( H ) [ 0 ] ) ) ) return H0 . copy ( ) return H
Rebuild the Hessian after making a change to the internal coordinate system.
Rebuild the Hessian after making a change to the internal coordinate system .
"""
    Rebuild the Hessian after making a change to the internal coordinate system.

    Parameters
    ----------
    IC : InternalCoordinates
        Object describing the internal coordinate system
    H0 : np.ndarray
        N_ic x N_ic square matrix containing the guess Hessian
    coord_seq : list
        List of N_atom x 3 Cartesian coordinates in atomic units
    grad_seq : list
        List of N_atom x 3 Cartesian gradients in atomic units
    params : OptParams object
        Uses trust, epsilon, and reset
        trust : Only recover using previous geometries within the trust radius
        epsilon : Small eigenvalue threshold
        reset : Revert to the guess Hessian if eigenvalues smaller than threshold

    Returns
    -------
    np.ndarray
        Internal coordinate Hessian updated with series of internal coordinate gradients
    """ # Mat1 = (Dg*Dg.T)/(Dg.T*Dy)[0,0] # Mat2 = ((H*Dy)*(H*Dy).T)/(Dy.T*H*Dy)[0,0]
IC
H0
coord_seq
grad_seq
params