Exemple #1
0
def get_eigs(Ei, Eij, T=0.05):
    from pele.utils.hessian import sort_eigs
    m = make_rate_matrix(Ei, Eij, T=T)
    lam, v = np.linalg.eig(m)
    lam, v = sort_eigs(lam, v)
    print "exact eigenvalues", sorted(-lam)
    print "exact eigenvectors"
    print v
Exemple #2
0
def normalmodes(hessian, metric=None, eps=1e-4, symmetric=False):
    """calculate (squared) normal mode frequencies and normal mode vectors

    Parameters
    ----------
    hessian: array
        hessian marix
    metric: array
        mass weighted metric tensor
    symmetric: bool
        If true, the Hessian times the metric tensor is assumed to be symmetric.  This is
        not usually the case, even if the metric tensor is symmetric.  It is
        true if the metric tensor is the identity.

    Returns
    -------
    freq, evecs tuple array of squared frequencies and normal modes

    """
    if metric is None:
        A = hessian
        symmetric = True
    else:
        A = np.dot(np.linalg.pinv(metric), hessian)

    if symmetric:
        freq, evecs = np.linalg.eigh(A)
    else:
        freq, evecs = np.linalg.eig(A)

    if np.max(np.abs(np.imag(freq))) > eps:
        print freq
        raise ValueError(
            "imaginary eigenvalue in frequency calculation"
            ", check hessian + metric tensor\nthe largest imaginary part is %g"
            % np.max(np.abs(np.imag(freq))))

    freq = np.real(freq)
    freq, evecs = sort_eigs(freq, evecs)
    return freq, evecs
Exemple #3
0
def normalmodes(hessian, metric=None, eps=1e-4, symmetric=False):
    """calculate (squared) normal mode frequencies and normal mode vectors

    Parameters
    ----------
    hessian: array
        hessian marix
    metric: array
        mass weighted metric tensor
    symmetric: bool
        If true, the Hessian times the metric tensor is assumed to be symmetric.  This is
        not usually the case, even if the metric tensor is symmetric.  It is
        true if the metric tensor is the identity.

    Returns
    -------
    freq, evecs tuple array of squared frequencies and normal modes

    """
    if metric is None:
        A = hessian
        symmetric = True
    else:
        A = np.dot(np.linalg.pinv(metric), hessian)

    if symmetric:
        freq, evecs = np.linalg.eigh(A)
    else:
        freq, evecs = np.linalg.eig(A)

    if np.max(np.abs(np.imag(freq))) > eps:
        print(freq)
        raise ValueError("imaginary eigenvalue in frequency calculation"
                         ", check hessian + metric tensor\nthe largest imaginary part is %g" % np.max(
            np.abs(np.imag(freq))))

    freq = np.real(freq)
    freq, evecs = sort_eigs(freq, evecs)
    return freq, evecs