コード例 #1
0
ファイル: MINDO3.py プロジェクト: gabrielelanaro/pyquante
def scfopen(atoms, F0, nalpha, nbeta, **opts):
    "SCF procedure for open-shell molecules"
    verbose = opts.get("verbose", False)
    D = get_guess_D(atoms)
    Da = 0.5 * D
    Db = 0.5 * D
    Eold = 0
    for i in xrange(10):
        F1a = get_F1_open(atoms, Da, Db)
        F1b = get_F1_open(atoms, Db, Da)
        F2a = get_F2_open(atoms, Da, Db)
        F2b = get_F2_open(atoms, Db, Da)
        Fa = F0 + F1a + F2a
        Fb = F0 + F1b + F2b
        Eel = 0.5 * trace2(Da, F0 + Fa) + 0.5 * trace2(Db, F0 + Fb)
        if verbose:
            print i, Eel
        if abs(Eel - Eold) < 0.001:
            break
        Eold = Eel
        orbea, orbsa = eigh(Fa)
        orbeb, orbsb = eigh(Fb)
        Da = mkdens(orbsa, 0, nalpha)
        Db = mkdens(orbsb, 0, nbeta)
    return Eel
コード例 #2
0
ファイル: LA2.py プロジェクト: berquist/PyQuante
def geigh(H,A,**kwargs):
    """\
    Generalized eigenproblem using a symmetric matrix H.

    Options:
    have_xfrm  False   Need to form canonical transformation from S (default)
               True    A is the canonical transformation matrix
    orthog     'Sym'   Use Symmetric Orthogonalization (default)
               'Can'   Use Canonical Orthogonalization
               'Chol'  Use a Cholesky decomposition
               'Cut'   Use a symmetric orthogonalization with a cutoff
                
    """
    have_xfrm = kwargs.get('have_xfrm')
    orthog = kwargs.get('orthog',settings.OrthogMethod)
    if not have_xfrm:
        if orthog == 'Can':
            X = CanOrth(A)
        elif orthog == 'Chol':
            X = CholOrth(A)
        elif orthog == 'Cut':
            X = SymOrthCutoff(A)
        else:
            X = SymOrth(A)
        kwargs['have_xfrm'] = True
        return geigh(H,X,**kwargs)
    val,vec = eigh(simx(H,A))
    vec = matrixmultiply(A,vec)
    return val,vec
コード例 #3
0
ファイル: MINDO3.py プロジェクト: gabrielelanaro/pyquante
def scfclosed(atoms, F0, nclosed, **opts):
    "SCF procedure for closed-shell molecules"
    verbose = opts.get("verbose", False)
    do_avg = opts.get("avg", False)
    maxiter = opts.get("maxiter", 50)
    D = get_guess_D(atoms)
    Eold = 0
    if do_avg:
        avg = SimpleAverager(do_avg)
    for i in xrange(maxiter):
        if do_avg:
            D = avg.getD(D)
        F1 = get_F1(atoms, D)
        F2 = get_F2(atoms, D)
        F = F0 + F1 + F2
        Eel = 0.5 * trace2(D, F0 + F)
        if verbose:
            print i + 1, Eel, get_Hf(atoms, Eel)
        # if verbose: print i+1,Eel
        if abs(Eel - Eold) < 0.001:
            if verbose:
                print "Exiting because converged", i + 1, Eel, Eold
            break
        Eold = Eel
        orbe, orbs = eigh(F)
        D = 2 * mkdens(orbs, 0, nclosed)
    return Eel
コード例 #4
0
def geigh(H, A, **kwargs):
    """\
    Generalized eigenproblem using a symmetric matrix H.

    Options:
    have_xfrm  False   Need to form canonical transformation from S (default)
               True    A is the canonical transformation matrix
    orthog     'Sym'   Use Symmetric Orthogonalization (default)
               'Can'   Use Canonical Orthogonalization
               'Chol'  Use a Cholesky decomposition
               'Cut'   Use a symmetric orthogonalization with a cutoff
                
    """
    have_xfrm = kwargs.get('have_xfrm')
    orthog = kwargs.get('orthog', settings.OrthogMethod)
    if not have_xfrm:
        if orthog == 'Can':
            X = CanOrth(A)
        elif orthog == 'Chol':
            X = CholOrth(A)
        elif orthog == 'Cut':
            X = SymOrthCutoff(A)
        else:
            X = SymOrth(A)
        kwargs['have_xfrm'] = True
        return geigh(H, X, **kwargs)
    val, vec = eigh(simx(H, A))
    vec = matrixmultiply(A, vec)
    return val, vec
コード例 #5
0
ファイル: LA2.py プロジェクト: berquist/PyQuante
def CanOrth(S): 
    """Canonical orthogonalization of matrix S. This is given by
    U(1/sqrt(lambda)), where lambda,U are the eigenvalues/vectors."""
    val,vec = eigh(S)
    n = vec.shape[0]
    for i in xrange(n):
        vec[:,i] = vec[:,i] / sqrt(val[i])
    return vec
コード例 #6
0
def CanOrth(S):
    """Canonical orthogonalization of matrix S. This is given by
    U(1/sqrt(lambda)), where lambda,U are the eigenvalues/vectors."""
    val, vec = eigh(S)
    n = vec.shape[0]
    for i in xrange(n):
        vec[:, i] = vec[:, i] / sqrt(val[i])
    return vec
コード例 #7
0
ファイル: LA2.py プロジェクト: berquist/PyQuante
def SymOrth(S):
    """Symmetric orthogonalization of the real symmetric matrix S.
    This is given by Ut(1/sqrt(lambda))U, where lambda,U are the
    eigenvalues/vectors."""
    val,vec = eigh(S)
    n = vec.shape[0]
    shalf = identity(n,'d')
    for i in xrange(n):
        shalf[i,i] /= sqrt(val[i])
    X = simx(shalf,vec,'T')
    return X
コード例 #8
0
def SymOrth(S):
    """Symmetric orthogonalization of the real symmetric matrix S.
    This is given by Ut(1/sqrt(lambda))U, where lambda,U are the
    eigenvalues/vectors."""
    val, vec = eigh(S)
    n = vec.shape[0]
    shalf = identity(n, 'd')
    for i in xrange(n):
        shalf[i, i] /= sqrt(val[i])
    X = simx(shalf, vec, 'T')
    return X
コード例 #9
0
def scfopen(atoms,F0,nalpha,nbeta,**kwargs):
    "SCF procedure for open-shell molecules"
    verbose = kwargs.get('verbose')
    D = get_guess_D(atoms)
    Da = 0.5*D
    Db = 0.5*D
    Eold = 0
    for i in xrange(10):
        F1a = get_F1_open(atoms,Da,Db)
        F1b = get_F1_open(atoms,Db,Da)
        F2a = get_F2_open(atoms,Da,Db)
        F2b = get_F2_open(atoms,Db,Da)
        Fa = F0+F1a+F2a
        Fb = F0+F1b+F2b
        Eel = 0.5*trace2(Da,F0+Fa)+0.5*trace2(Db,F0+Fb)
        if verbose: print i,Eel
        if abs(Eel-Eold) < 0.001: break
        Eold = Eel
        orbea,orbsa = eigh(Fa)
        orbeb,orbsb = eigh(Fb)
        Da = mkdens(orbsa,0,nalpha)
        Db = mkdens(orbsb,0,nbeta)
    return Eel
コード例 #10
0
ファイル: LA2.py プロジェクト: berquist/PyQuante
def SymOrthCutoff(S,scut=1e-5):
    """Symmetric orthogonalization of the real symmetric matrix S.
    This is given by Ut(1/sqrt(lambda))U, where lambda,U are the
    eigenvalues/vectors.

    Only eigenvectors with eigenvalues greater that a cutoff are kept.
    This approximation is useful in cases where the basis set has
    linear dependencies.
    """
    val,vec = eigh(S)
    n = vec.shape[0]
    shalf = identity(n,'d')
    for i in xrange(n):
        if val[i] > scut:
            shalf[i,i] /= sqrt(val[i])
        else:
            shalf[i,i] = 0.
    X = simx(shalf,vec,'T')
    return X
コード例 #11
0
def SymOrthCutoff(S, scut=1e-5):
    """Symmetric orthogonalization of the real symmetric matrix S.
    This is given by Ut(1/sqrt(lambda))U, where lambda,U are the
    eigenvalues/vectors.

    Only eigenvectors with eigenvalues greater that a cutoff are kept.
    This approximation is useful in cases where the basis set has
    linear dependencies.
    """
    val, vec = eigh(S)
    n = vec.shape[0]
    shalf = identity(n, 'd')
    for i in xrange(n):
        if val[i] > scut:
            shalf[i, i] /= sqrt(val[i])
        else:
            shalf[i, i] = 0.
    X = simx(shalf, vec, 'T')
    return X
コード例 #12
0
def scfclosed(atoms,F0,nclosed,**kwargs):
    "SCF procedure for closed-shell molecules"
    verbose = kwargs.get('verbose')
    do_avg = kwargs.get('avg',settings.MINDOAveraging)
    maxiter = kwargs.get('maxiter',settings.MaxIter)
    D = get_guess_D(atoms)
    Eold = 0
    if do_avg: avg = SimpleAverager(do_avg)
    for i in xrange(maxiter):
        if do_avg: D = avg.getD(D)
        F1 = get_F1(atoms,D)
        F2 = get_F2(atoms,D)
        F = F0+F1+F2
        Eel = 0.5*trace2(D,F0+F)
        if verbose: print i+1,Eel,get_Hf(atoms,Eel)
        #if verbose: print i+1,Eel
        if abs(Eel-Eold) < 0.001:
            if verbose:
                print "Exiting because converged",i+1,Eel,Eold
            break
        Eold = Eel
        orbe,orbs = eigh(F)
        D = 2*mkdens(orbs,0,nclosed)
    return Eel
コード例 #13
0
def CIS(Ints, orbs, orbe, nocc, nvirt, ehf):
    CIMatrix = CISMatrix(Ints, orbs, ehf, orbe, nocc, nvirt)
    Ecis, Vectors = eigh(CIMatrix)
    return Ecis
コード例 #14
0
ファイル: CI.py プロジェクト: berquist/PyQuante
def CIS(Ints,orbs,orbe,nocc,nvirt,ehf):
    CIMatrix = CISMatrix(Ints,orbs,ehf,orbe,nocc,nvirt)
    Ecis,Vectors = eigh(CIMatrix)
    return Ecis