Beispiel #1
0
def uhf_simple(geo,basisname='sto3g',maxiter=25,verbose=False):
    if geo.nopen() == 0: return scf_simple(geo,basisname,maxiter,verbose)
    bfs = basisset(geo,basisname)
    i1 = onee_integrals(bfs,geo)
    i2 = twoe_integrals(bfs)
    h = i1.T + i1.V
    E,U = geigh(h,i1.S)
    Enuke = geo.nuclear_repulsion()
    Eold = Energy = 0
    ca = cb = U
    na,nb = geo.nup(),geo.ndown()

    for i in xrange(maxiter):
        Energy = Enuke
        Da = dmat(ca,na)
        Db = dmat(cb,nb)
        h = i1.T + i1.V
        Energy += trace2(Da+Db,h)/2
        Ja,Ka = i2.get_j(Da),i2.get_k(Da)
        Jb,Kb = i2.get_j(Db),i2.get_k(Db)
        Fa = h + Ja + Jb - Ka
        Fb = h + Ja + Jb - Kb
        orbea,ca = geigh(Fa,i1.S)
        orbeb,cb = geigh(Fb,i1.S)
        Energy += trace2(Fa,Da)/2 + trace2(Fb,Db)/2
        print ("UHF: %d   %10.4f : %10.4f" % ((i+1),Energy,Enuke))
        if np.isclose(Energy,Eold):
            break
        Eold = Energy
    else:
        print ("Warning: Maxiter %d hit in scf_simple" % maxiter)
    return Energy,E,U
Beispiel #2
0
def uhf_simple(geo,basisname='sto3g',maxiter=25,verbose=False):
    if geo.nopen() == 0: return scf_simple(geo,basisname,maxiter,verbose)
    bfs = basisset(geo,basisname)
    i1 = onee_integrals(bfs,geo)
    i2 = twoe_integrals(bfs)
    h = i1.T + i1.V
    E,U = geigh(h,i1.S)
    Enuke = geo.nuclear_repulsion()
    Eold = Energy = 0
    ca = cb = U
    na,nb = geo.nup(),geo.ndown()

    for i in xrange(maxiter):
        Energy = Enuke
        Da = dmat(ca,na)
        Db = dmat(cb,nb)
        h = i1.T + i1.V
        Energy += trace2(Da+Db,h)/2
        Ja,Ka = i2.get_j(Da),i2.get_k(Da)
        Jb,Kb = i2.get_j(Db),i2.get_k(Db)
        Fa = h + Ja + Jb - Ka
        Fb = h + Ja + Jb - Kb
        orbea,ca = geigh(Fa,i1.S)
        orbeb,cb = geigh(Fb,i1.S)
        Energy += trace2(Fa,Da)/2 + trace2(Fb,Db)/2
        print ("UHF: %d   %10.4f : %10.4f" % ((i+1),Energy,Enuke))
        if np.isclose(Energy,Eold):
            break
        Eold = Energy
    else:
        print ("Warning: Maxiter %d hit in scf_simple" % maxiter)
    return Energy,E,U
Beispiel #3
0
 def __next__(self):
     self.iterations += 1
     if self.iterations > self.maxiters:
         raise StopIteration
     Dup = dmat(self.c,self.nup)
     Ddown = dmat(self.c,self.ndown)
     self.c = self.H.update(Dup,Ddown,self.c)
     E = self.H.energy
     if abs(E-self.Eold) < self.tol:
         self.converged = True
         raise StopIteration
     self.Eold = E
     return E
Beispiel #4
0
def scf_simple(geo,basisname='sto-3g',maxiter=25,verbose=False):
    bfs = basisset(geo,basisname)
    i1 = onee_integrals(bfs,geo)
    i2 = twoe_integrals(bfs)
    if verbose: print ("S=\n%s" % i1.S)
    h = i1.T + i1.V
    if verbose: print ("h=\n%s" % h)
    if verbose: print ("T=\n%s" % i1.T)
    if verbose: print ("V=\n%s" % i1.V)
    E,U = geigh(h,i1.S)
    if verbose: print ("E=\n%s" % E)
    if verbose: print ("U=\n%s" % U)
    Enuke = geo.nuclear_repulsion()
    nocc = geo.nocc()
    Eold = Energy = 0
    if verbose: print ("2e ints\n%s" % i2)
    for i in xrange(maxiter):
        D = dmat(U,nocc)
        if verbose: print ("D=\n%s" % D)
        Eone = trace2(h,D)
        G = i2.get_2jk(D)
        H = h+G
        Etwo = trace2(H,D)
        E,U = geigh(H,i1.S)
        Energy = Enuke+Eone+Etwo
        print ("HF: %d   %10.4f : %10.4f %10.4f %10.4f" % ((i+1),Energy,Enuke,Eone,Etwo))
        if np.isclose(Energy,Eold):
            break
        Eold = Energy
    else:
        print ("Warning: Maxiter %d hit in scf_simple" % maxiter)
    return Energy,E,U
Beispiel #5
0
def rhf_simple(geo,basisname='sto3g',maxiter=25,verbose=False):
    bfs = basisset(geo,basisname)
    i1 = onee_integrals(bfs,geo)
    i2 = twoe_integrals(bfs)
    if verbose: print ("S=\n%s" % i1.S)
    h = i1.T + i1.V
    if verbose: print ("h=\n%s" % h)
    if verbose: print ("T=\n%s" % i1.T)
    if verbose: print ("V=\n%s" % i1.V)
    E,U = geigh(h,i1.S)
    if verbose: print ("E=\n%s" % E)
    if verbose: print ("U=\n%s" % U)
    Enuke = geo.nuclear_repulsion()
    nocc = geo.nocc()
    Eold = Energy = 0
    if verbose: print ("2e ints\n%s" % i2)
    for i in xrange(maxiter):
        D = dmat(U,nocc)
        if verbose: print ("D=\n%s" % D)
        Eone = trace2(h,D)
        G = i2.get_2jk(D)
        H = h+G
        Etwo = trace2(H,D)
        E,U = geigh(H,i1.S)
        Energy = Enuke+Eone+Etwo
        print ("HF: %d   %10.4f : %10.4f %10.4f %10.4f" % ((i+1),Energy,Enuke,Eone,Etwo))
        if np.isclose(Energy,Eold):
            break
        Eold = Energy
    else:
        print ("Warning: Maxiter %d hit in scf_simple" % maxiter)
    return Energy,E,U
Beispiel #6
0
 def __next__(self):
     D = (1-self.fraction)*self.Dold + self.fraction*dmat(self.c,self.H.geo.nocc())
     self.Dold = D
     self.c = self.H.update(D)
     E = self.H.energy
     if abs(E-self.Eold) < self.tol:
         self.converged = True
         raise StopIteration
     self.Eold = E
     return E
Beispiel #7
0
 def __next__(self):
     self.iterations += 1
     if self.iterations > self.maxiters:
         raise StopIteration
     D = dmat(self.c,self.H.geo.nocc())
     self.c = self.H.update(D)
     E = self.H.energy
     if abs(E-self.Eold) < self.tol:
         self.converged = True
         raise StopIteration
     self.Eold = E
     return E
Beispiel #8
0
 def __next__(self):
     self.iterations += 1
     if self.iterations > self.maxiters:
         raise StopIteration
     nc,no = self.H.geo.nclosed(),self.H.geo.nopen()
     if no != 0:
         print ("Warning: nopen != 0 in SCF Iterator: %d" % no )
     D = dmat(self.c,nc,no)
     self.c = self.H.update(D)
     E = self.H.energy
     if abs(E-self.Eold) < self.tol:
         self.converged = True
         raise StopIteration
     self.Eold = E
     return E
Beispiel #9
0
 def density(self, orbs):
     """ Electron density"""
     return dmat(orbs, self.nocc)
Beispiel #10
0
 def density(self, orbs):
     Da = dmat(orbs, self.nup)
     Db = dmat(orbs, self.ndown)
     return Da, Db
Beispiel #11
0
import numpy as np

from pyquante2 import basisset
from pyquante2.grid.grid import grid
from pyquante2.utils import dmat
from pyquante2.geo.samples import he
from pyquante2.graphics.maya import view_dft_density
#from mayavi import mlab
#from scipy.interpolate import griddata

bfs = basisset(he)
he_grid = grid(he)
he_grid.setbfamps(bfs)
nbf = len(bfs)
C = np.eye(nbf)
D = dmat(C,he.nocc())
view_dft_density(he_grid,D,(-1,1,-1,1,-1,1))
Beispiel #12
0
import numpy as np

from pyquante2 import basisset
from pyquante2.grid.grid import grid
from pyquante2.utils import dmat
from pyquante2.geo.samples import he
from pyquante2.graphics.maya import view_dft_density
#from mayavi import mlab
#from scipy.interpolate import griddata

bfs = basisset(he)
he_grid = grid(he)
he_grid.setbfamps(bfs)
nbf = len(bfs)
C = np.eye(nbf)
D = dmat(C, he.nocc())
view_dft_density(he_grid, D, (-1, 1, -1, 1, -1, 1))
Beispiel #13
0
 def __init__(self,H,c=None,fraction=0.5,tol=1e-5,maxiters=100):
     SCFIterator.__init__(self,H,c,tol,maxiters)
     self.fraction = fraction
     self.Dold = dmat(self.c,self.H.geo.nocc())
     return