def test_ke_cutoff(pseudo=None): # The periodic calculation eke_cut = [] eno_cut = [] max_ke = [] Ls = [5, 10, 15, 20, 25, 30, 40, 50] for L in Ls: cell = pbcgto.Cell() cell.unit = 'B' cell.h = np.diag([L,L,L]) cell.gs = np.array([20,20,20]) cell.nimgs = [0,0,0] cell.atom = [['He', (L/2.,L/2.,L/2.)]] cell.basis = { 'He': [[0, (0.8, 1.0)], [0, (1.0, 1.0)], [0, (1.2, 1.0)]] } cell.pseudo = pseudo cell.ke_cutoff = 10 cell.build() mf = pbcrks.RKS(cell) max_ke.append(np.max(0.5*np.einsum('gi,gi->g', cell.Gv, cell.Gv))) eke_cut.append(mf.scf()) cell.ke_cutoff = None cell.build() mf = pbcrks.RKS(cell) eno_cut.append(mf.scf()) # The basic idea is that for a fixed Ke cutoff, the # basis functions do not change too much even when # the box volume is being changed. So, one should # find that the energy dependence with box size is smaller # when a KE cutoff is employed. for i, L in enumerate(Ls): print "Ke Cutoff, L: %d, %f, %f" % (L, eke_cut[i], max_ke[i]) # Ke Cutoff, L: 5, -2.468773, 947.482023 # Ke Cutoff, L: 10, -2.466350, 236.870506 # Ke Cutoff, L: 15, -2.465358, 105.275780 # Ke Cutoff, L: 20, -2.462961, 59.217626 # Ke Cutoff, L: 25, -2.421159, 37.899281 # Ke Cutoff, L: 30, -2.263560, 26.318945 # Ke Cutoff, L: 40, -2.278470, 14.804407 # Ke Cutoff, L: 50, -3.386092, 9.474820 for i, L in enumerate(Ls): print "No Cutoff, L: %d, %f, %f" % (L, eno_cut[i], max_ke[i])
def test_kscf_gamma(atom, ncells): import numpy as np # import warnings cell = pbcgto.Cell() cell.unit = 'B' # As this is increased, we can see convergence between the molecule # and cell calculation Lunit = 2 Ly = Lz = 2 Lx = ncells * Lunit cell.a = np.diag([Lx, Ly, Lz]) # place atom in middle of big box for i in range(ncells): cell.atom.extend([[atom, ((.5 + i) * Lunit, 0.5 * Ly, 0.5 * Lz)]]) cell.basis = {atom: [[0, (1.0, 1.0)]]} n = 40 cell.gs = np.array([n * ncells, n, n]) cell.nimgs = [2, 2, 2] cell.verbose = 7 cell.build() #warnings.simplefilter("error", np.ComplexWarning) kmf = pbcrks.RKS(cell) kmf.init_guess = "atom" return kmf.scf()
def test_ks(pseudo=None): # The molecular calculation mol = gto.Mole() mol.unit = 'B' L = 10 mol.atom.extend([ ['He', (L / 2., L / 2., L / 2.)], ]) # these are some exponents which are not hard to integrate mol.basis = {'He': [[0, (0.8, 1.0)], [0, (1.0, 1.0)], [0, (1.2, 1.0)]]} mol.build() m = rks.RKS(mol) m.xc = 'LDA,VWN_RPA' #m.xc = 'B88,LYP' print "Molecular DFT energy" print(m.scf()) # LDA,VWN_RPA # -2.64096172441 # BLYP # -2.66058401340308 # The periodic calculation cell = pbcgto.Cell() cell.unit = 'B' cell.h = np.diag([L, L, L]) cell.gs = np.array([80, 80, 80]) cell.nimgs = [1, 1, 1] cell.atom = mol.atom cell.basis = mol.basis cell.pseudo = pseudo cell.build() mf = pbcrks.RKS(cell) mf.xc = 'LDA,VWN_RPA' # mf.xc = 'B88,LYP' print(mf.scf())
def KS(cell, *args, **kwargs): if cell.spin == 0: return rks.RKS(cell, *args, **kwargs) else: return uks.UKS(cell, *args, **kwargs)
def RKS(cell, *args, **kwargs): if cell.spin == 0: return rks.RKS(cell, *args, **kwargs) else: return roks.ROKS(cell, *args, **kwargs)