Beispiel #1
0
def test_cubic_diamond_C():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
    print "Cell volume =", ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"

    cell.gs = np.array([10, 10, 10])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int = False
    mf.xc = 'lda,vwn'
    print mf.scf()

    # Gamma point gs: 10x10x10: -11.220279983393
    #             gs: 14x14x14: -11.220122248175
    # K pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2, 2, 2))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    kmf.verbose = 7
    print kmf.scf()
Beispiel #2
0
    def test_coulG(self):
        numpy.random.seed(19)
        kpt = numpy.random.random(3)
        ase_atom = bulk('C', 'diamond', a=3.5668)
        cell = pbcgto.Cell()
        cell.unit = 'A'
        cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        cell.a = ase_atom.cell + numpy.random.random((3,3)).T
        cell.basis = 'gth-szv'
        cell.pseudo = 'gth-pade'
        cell.gs = [5,4,3]
        cell.verbose = 5
        cell.output = '/dev/null'
        cell.build()
        coulG = tools.get_coulG(cell, kpt)
        self.assertAlmostEqual(finger(coulG), 62.75448804333378, 9)

        cell.a = numpy.eye(3)
        cell.unit = 'B'
        coulG = tools.get_coulG(cell, numpy.array([0, numpy.pi, 0]))
        self.assertAlmostEqual(finger(coulG), 4.6737453679713905, 9)
        coulG = tools.get_coulG(cell, numpy.array([0, numpy.pi, 0]),
                                wrap_around=False)
        self.assertAlmostEqual(finger(coulG), 4.5757877990664744, 9)
        coulG = tools.get_coulG(cell, exx='ewald')
        self.assertAlmostEqual(finger(coulG), 4.888843468914021, 9)
def get_cell(lc_bohr, atom, unit_cell, basis, mesh, pseudo, supercell=None):

    cell = pbcgto.Cell()
    boxlen = lc_bohr
    ase_atom = ase.build.bulk(atom, unit_cell, a=boxlen)
    cell.a = ase_atom.cell
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.basis = basis
    cell.charge = 0
    cell.dimension = 3
    cell.incore_anyway = False
    cell.max_memory = 8000
    cell.mesh = numpy.array([mesh, mesh, mesh])
    cell.pseudo = pseudo
    cell.spin = 0
    cell.unit = 'B'
    cell.verbose = 10
    print "*****BUILDING CELL!*****"
    cell.build()

    if supercell is not None:
        print "*****BUILDING SUPERCELL!*****"
        cell._built = False
        cell = pbctools.super_cell(cell, supercell)

    return cell
Beispiel #4
0
def run_lda(ase_atom, ngs, nmp=1):
    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])

    #cell.verbose = 4
    cell.build()

    print "-- The Gamma point calculation -----------"
    mf = pbcdft.RKS(cell)
    mf.xc = 'lda,vwn'
    #mf.verbose = 7
    print mf.scf()

    print "-- The k-point sampling calculation ------"
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((nmp,nmp,nmp))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)
    kmf = pbcdft.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    #kmf.verbose = 7
    print kmf.scf()
Beispiel #5
0
    def test_coulG(self):
        numpy.random.seed(19)
        kpt = numpy.random.random(3)
        ase_atom = bulk('C', 'diamond', a=3.5668)
        cell = pbcgto.Cell()
        cell.unit = 'A'
        cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        cell.a = ase_atom.cell + numpy.random.random((3, 3)).T
        cell.basis = 'gth-szv'
        cell.pseudo = 'gth-pade'
        cell.gs = [5, 4, 3]
        cell.verbose = 5
        cell.output = '/dev/null'
        cell.build()
        coulG = tools.get_coulG(cell, kpt)
        self.assertAlmostEqual(finger(coulG), 62.75448804333378, 9)

        cell.a = numpy.eye(3)
        cell.unit = 'B'
        coulG = tools.get_coulG(cell, numpy.array([0, numpy.pi, 0]))
        self.assertAlmostEqual(finger(coulG), 4.6737453679713905, 9)
        coulG = tools.get_coulG(cell,
                                numpy.array([0, numpy.pi, 0]),
                                wrap_around=False)
        self.assertAlmostEqual(finger(coulG), 4.5757877990664744, 9)
        coulG = tools.get_coulG(cell, exx='ewald')
        self.assertAlmostEqual(finger(coulG), 4.888843468914021, 9)
Beispiel #6
0
def test_cubic_diamond_C():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
    print "Cell volume =", ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"

    cell.gs = np.array([10,10,10])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int = False
    mf.xc = 'lda,vwn'
    print mf.scf()

    # Gamma point gs: 10x10x10: -11.220279983393
    #             gs: 14x14x14: -11.220122248175
    # K pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    kmf.verbose = 7
    print kmf.scf()
Beispiel #7
0
def build_cell(ase_atom,
               unit='B',
               ke=20.0,
               gsmax=None,
               basis='gth-szv',
               pseudo='gth-pade',
               dimension=3,
               incore_anyway=False):
    cell = pbcgto.Cell()
    cell.unit = unit
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell

    cell.basis = basis
    cell.pseudo = pseudo
    cell.dimension = dimension

    cell.incore_anyway = incore_anyway

    if gsmax is not None:
        cell.gs = np.array([gsmax, gsmax, gsmax])
    else:
        cell.ke_cutoff = ke

    cell.build()
    return cell
Beispiel #8
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(c)
    cell.a=c.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs=np.array([5,5,5])
    cell.verbose=7
    cell.build(None,None)
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((1,1,1))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
 
    e_kn = []
    for kpt in band_kpts:
        fb, sb=kmf.get_band_fock_ovlp(kmf.get_hcore()+kmf.get_veff(),
                                      kmf.get_ovlp(), kpt)
        e, c=hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)
    
    emin = -1 
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
Beispiel #9
0
def test_band_ase_kpts():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    c = bulk('C', 'diamond', a=3.5668)
    print c.get_volume()
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], c.cell, npoints=30)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
    cell.h = c.cell.T

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([5, 5, 5])
    cell.verbose = 7
    cell.build(None, None)

    scaled_kpts = ase.dft.kpoints.monkhorst_pack((1, 1, 1))
    abs_kpts = cell.get_abs_kpts(scaled_kpts)

    kmf = pbckscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.xc = 'lda,vwn'
    print kmf.scf()

    e_kn = []
    for kpt in band_kpts:
        fb, sb = kmf.get_band_fock_ovlp(kmf.get_hcore() + kmf.get_veff(),
                                        kmf.get_ovlp(), kpt)
        e, c = hf.eig(fb, sb)
        print kpt, e
        e_kn.append(e)

    emin = -1
    emax = 2

    plt.figure(figsize=(5, 6))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', 'G', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')

    plt.show()
Beispiel #10
0
def build_cell(ase_atom, ngs):
    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.a = ase_atom.cell
    cell.gs = np.array([ngs,ngs,ngs])

    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.verbose = 0
    cell.build()
    return cell
Beispiel #11
0
def build_cell(ase_atom, ngs):
    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.h = ase_atom.cell.T
    cell.gs = np.array([ngs, ngs, ngs])

    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.verbose = 0
    cell.build()
    return cell
Beispiel #12
0
    def from_ase(self, ase_atom):
        '''Update cell based on given ase atom object

        Examples:

        >>> from ase.lattice import bulk
        >>> cell.from_ase(bulk('C', 'diamond', a=LATTICE_CONST))
        '''
        from pyscf.pbc.tools import pyscf_ase
        self.h = ase_atom.cell
        self.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        return self
Beispiel #13
0
    def from_ase(self, ase_atom):
        '''Update cell based on given ase atom object

        Examples:

        >>> from ase.lattice import bulk
        >>> cell.from_ase(bulk('C', 'diamond', a=LATTICE_CONST))
        '''
        from pyscf.pbc.tools import pyscf_ase
        self.a = ase_atom.cell
        self.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        return self
Beispiel #14
0
def test_diamond_C():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    C = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(C)
    cell.a = C.cell

    # cell.basis = 'gth-tzvp'
    cell.basis = 'gth-szv'
    # cell.basis = {'C': [[0, (4.3362376436, 0.1490797872), (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051), (0.1187877657, -0.3964426906)], [1, (4.3362376436, -0.0878123619), (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093), (0.1187877657, -0.4058039291)]]}
    # Easier basis for quick testing
    #cell.basis = {'C': [[0, (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051)], [1, (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093) ]]}

    # Cell used for K-points
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([8, 8, 8])
    cell.verbose = 7
    cell.build(None, None)

    # Replicate cell NxNxN for comparison
    # repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    # repcell.gs = np.array([12,12,12]) # for 3 replicated cells, then
    # #                                 # ngs must be of the form [3gs0 + 1, gs1, gs2]
    # repcell.build()
    # # # Replicated MF calc
    # mf = pbcdft.RKS(repcell)
    # # mf.analytic_int = True
    # mf.xc = 'lda,vwn'
    # mf.init_guess = '1e'
    # mf.diis = True
    # mf.scf()

    # K-pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2, 2, 2))

    # shift if 2x2x2 includes Gamma point
    # shift = np.array([1./4., 1./4., 1./4.])
    # scaled_kpts += shift
    abs_kpts = cell.get_abs_kpts(scaled_kpts)
    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.diis = True
    kmf.init_guess = '1e'
    kmf.xc = 'lda,vwn'
    print "N imgs", cell.nimgs
    print "Cutoff for 400 eV", pyscf.pbc.tools.cutoff_to_gs(
        cell.lattice_vectors(), 400 / 27.2)

    #kmf.max_cycle = 3
    kmf.scf()
Beispiel #15
0
def test_diamond_C():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    C = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(C)
    cell.h = C.cell

    # cell.basis = 'gth-tzvp'
    cell.basis = 'gth-szv'
    # cell.basis = {'C': [[0, (4.3362376436, 0.1490797872), (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051), (0.1187877657, -0.3964426906)], [1, (4.3362376436, -0.0878123619), (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093), (0.1187877657, -0.4058039291)]]}
    # Easier basis for quick testing
    #cell.basis = {'C': [[0, (1.2881838513, -0.0292640031), (0.4037767149, -0.688204051)], [1, (1.2881838513, -0.27755603), (0.4037767149, -0.4712295093) ]]}

    # Cell used for K-points
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([8,8,8])
    cell.verbose = 7
    cell.build(None,None)

    # Replicate cell NxNxN for comparison
    # repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    # repcell.gs = np.array([12,12,12]) # for 3 replicated cells, then
    # #                                 # ngs must be of the form [3gs0 + 1, gs1, gs2]
    # repcell.build()
    # # # Replicated MF calc
    # mf = pbcdft.RKS(repcell)
    # # mf.analytic_int = True
    # mf.xc = 'lda,vwn'
    # mf.init_guess = '1e'
    # mf.diis = True
    # mf.scf()
    
    # K-pt calc
    scaled_kpts = ase.dft.kpoints.monkhorst_pack((2,2,2))

    # shift if 2x2x2 includes Gamma point
    # shift = np.array([1./4., 1./4., 1./4.])
    # scaled_kpts += shift
    abs_kpts = cell.get_abs_kpts(scaled_kpts)
    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int = False
    kmf.diis = True
    kmf.init_guess = '1e'
    kmf.xc = 'lda,vwn'
    print "N imgs", cell.nimgs
    print "Cutoff for 400 eV", pyscf.pbc.tools.cutoff_to_gs(cell.lattice_vectors(), 400/27.2)

    #kmf.max_cycle = 3
    kmf.scf() 
Beispiel #16
0
 def test_coulG(self):
     numpy.random.seed(19)
     kpt = numpy.random.random(3)
     ase_atom = bulk('C', 'diamond', a=3.5668)
     cell = pbcgto.Cell()
     cell.unit = 'A'
     cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
     cell.h = ase_atom.cell + numpy.random.random((3, 3))
     cell.basis = 'gth-szv'
     cell.pseudo = 'gth-pade'
     cell.gs = [5, 4, 3]
     cell.verbose = 5
     cell.output = '/dev/null'
     cell.build()
     coulG = tools.get_coulG(cell, kpt)
     self.assertAlmostEqual(finger(coulG), 62.75448804333378, 9)
Beispiel #17
0
def make_primitive_cell(ngs):
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs, ngs, ngs])

    #cell.nimgs = np.array([7,7,7])
    cell.verbose = 0
    cell.build()
    return cell
Beispiel #18
0
 def test_coulG_ws(self):
     ase_atom = bulk('C', 'diamond', a=3.5668)
     cell = pbcgto.Cell()
     cell.unit = 'A'
     cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
     cell.a = ase_atom.cell
     cell.basis = 'gth-szv'
     cell.pseudo = 'gth-pade'
     cell.gs = [5] * 3
     cell.verbose = 5
     cell.output = '/dev/null'
     cell.build()
     mf = khf.KRHF(cell, exxdiv='vcut_ws')
     mf.kpts = cell.make_kpts([2, 2, 2])
     coulG = tools.get_coulG(cell, mf.kpts[2], True, mf)
     self.assertAlmostEqual(finger(coulG), 1.3245117871351604, 9)
Beispiel #19
0
def GetMP():
    ase_atom = ase.build.bulk(atomtype, unittype, a=lc)
    cell = pbcgto.Cell()
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell  #lattice vectors
    cell.ke_cutoff = ecut  #kinetic energy cutoff
    cell.precision = 1.e-8
    cell.dimension = 3  #3D PBC
    cell.unit = 'B'  #Bohr
    cell.build()
    k = cell.make_kpts(kpts, wrap_around=True)  #get k-points from PySCF
    a = cell.a  #real lattice vectors
    h = cell.reciprocal_vectors()  #reciprocal lattice vectors
    omega = np.linalg.det(a)  #cell volume

    return k, a, h, omega, cell
Beispiel #20
0
def make_primitive_cell(ngs):
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])

    #cell.nimgs = np.array([7,7,7])
    cell.verbose = 0
    cell.build()
    return cell
Beispiel #21
0
 def test_coulG_ws(self):
     ase_atom = bulk('C', 'diamond', a=3.5668)
     cell = pbcgto.Cell()
     cell.unit = 'A'
     cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
     cell.a = ase_atom.cell
     cell.basis = 'gth-szv'
     cell.pseudo = 'gth-pade'
     cell.gs = [5]*3
     cell.verbose = 5
     cell.output = '/dev/null'
     cell.build()
     mf = khf.KRHF(cell, exxdiv='vcut_ws')
     mf.kpts = cell.make_kpts([2,2,2])
     coulG = tools.get_coulG(cell, mf.kpts[2], True, mf)
     self.assertAlmostEqual(finger(coulG), 1.3245117871351604, 9)
Beispiel #22
0
def make_primitive_cell(ngs):
    from ase.lattice import bulk
    ase_atom = ase.build.bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs, ngs, ngs])

    cell.verbose = 5
    cell.output = '/dev/null'
    cell.build()
    return cell
Beispiel #23
0
def make_primitive_cell(ngs):
    from ase.lattice import bulk

    ase_atom = bulk("C", "diamond", a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = "A"
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell

    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"
    cell.gs = np.array([ngs, ngs, ngs])

    # cell.verbose = 4
    cell.build()
    return cell
Beispiel #24
0
def test():

    ANALYTIC=False
    ase_atom=bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell
    cell.verbose = 7

    # gth-szv for C
    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'

    cell.gs = np.array([4,1,1])
    cell.build(None, None)

    print "N images: ", cell.nimgs
    cell.nimgs = [10,1,1]
    repcell = pyscf.pbc.tools.replicate_cell(cell, (3,1,1))
    print "REPCELL", repcell.pseudo

    mf = pbcdft.RKS(repcell)
    mf.verbose = 5
    mf.diis = False
    mf.analytic_int=ANALYTIC
    mf.xc = 'lda,vwn'
    mf.max_cycle = 1
    mf.init_guess = '1e'
    mf.scf()

    scaled_kpts=np.array(ase.dft.kpoints.monkhorst_pack((3,1,1)))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    cell.gs = np.array([1,1,1])
    cell.nimgs = [14,1,1]
    cell.build(None, None)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=ANALYTIC
    kmf.diis = False
    kmf.verbose = 5
    kmf.xc = 'lda,vwn'
    kmf.max_cycle = 1
    kmf.init_guess = '1e'
    kmf.scf()
Beispiel #25
0
def make_primitive_cell(ngs):
    from ase.lattice import bulk
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell

    cell.basis = 'gth-szv'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])

    cell.verbose = 5
    cell.output = '/dev/null'
    cell.build()
    return cell
Beispiel #26
0
def run_hf(ase_atom, ngs):
    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell

    cell.basis = 'gth-szv'
    #cell.basis = 'gth-dzvp'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])

    #cell.verbose = 4
    cell.build()

    print "-- The Gamma point calculation -----------"
    mf = pbchf.RHF(cell)
    mf.verbose = 7
    print mf.scf()
    print mf.mo_energy
Beispiel #27
0
    def test_klda8_cubic_kpt_222(self):
        ase_atom = Diamond(symbol='C', latticeconstant=LATTICE_CONST)
        cell = pbcgto.Cell()
        cell.unit = 'A'
        cell.h = ase_atom.cell
        cell.gs = np.array([8]*3)
        cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        cell.basis = 'gth-szv'
        cell.pseudo = 'gth-pade'
        cell.verbose = 5
        cell.output = '/dev/null'
        cell.build()

        kpts = cell.make_kpts((2,2,2))
        mf = pbcdft.KUKS(cell, kpts)
        mf.xc = 'lda,vwn'
        e1 = mf.scf()
        self.assertAlmostEqual(e1, -45.42583489512954, 8)
        self.assertAlmostEqual(mf._ecoul, 3.2519161200384685, 8)
        self.assertAlmostEqual(mf._exc, -13.937886385300949, 8)
Beispiel #28
0
def build_cell(ase_atom, unit='B', ke=20.0, gsmax=None, basis='gth-szv', 
               pseudo='gth-pade', dimension=3, incore_anyway=False):
    cell = pbcgto.Cell()
    cell.unit = unit
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell

    cell.basis = basis
    cell.pseudo = pseudo
    cell.dimension = dimension

    cell.incore_anyway = incore_anyway

    if gsmax is not None:
        cell.gs = np.array([gsmax,gsmax,gsmax])
    else:
        cell.ke_cutoff = ke

    cell.build()
    return cell
Beispiel #29
0
    def test_klda8_cubic_kpt_222(self):
        ase_atom = Diamond(symbol="C", latticeconstant=LATTICE_CONST)
        cell = pbcgto.Cell()
        cell.unit = "A"
        cell.h = ase_atom.cell
        cell.gs = np.array([8] * 3)
        cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
        cell.basis = "gth-szv"
        cell.pseudo = "gth-pade"
        cell.verbose = 5
        cell.output = "/dev/null"
        cell.build()

        kpts = cell.make_kpts((2, 2, 2))
        mf = pbcdft.KUKS(cell, kpts)
        mf.xc = "lda,vwn"
        e1 = mf.scf()
        self.assertAlmostEqual(e1, -45.42583489512954, 8)
        self.assertAlmostEqual(mf._ecoul, 3.2519161200384685, 8)
        self.assertAlmostEqual(mf._exc, -13.937886385300949, 8)
Beispiel #30
0
def test_cell_n3(ngs):
    import ase
    import pyscf.pbc.tools.pyscf_ase as pyscf_ase
    import ase.lattice
    from ase.lattice import bulk
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.a = ase_atom.cell
    #cell.basis = "gth-dzvp"
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"
    cell.gs = np.array([ngs, ngs, ngs])

    cell.build()
    return cell
Beispiel #31
0
def test_cell_n3( ngs ):
    import ase
    import pyscf.pbc.tools.pyscf_ase as pyscf_ase
    import ase.lattice
    from ase.lattice import bulk
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom = bulk('C', 'diamond', a=3.5668)

    cell = pbcgto.Cell()
    cell.unit = 'A'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell
    #cell.basis = "gth-dzvp"
    cell.basis = "gth-szv"
    cell.pseudo = "gth-pade"
    cell.gs = np.array([ngs,ngs,ngs])

    cell.build()
    return cell
Beispiel #32
0
def test_cubic_diamond_He():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom=Diamond(symbol='He', latticeconstant=3.5)
    print ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell.T
    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    cell.gs = np.array([15,15,15])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic: -18.2278622592408

    mf = pbcdft.RKS(cell)
    mf.analytic_int=True
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic (analytic): -18.2278622592283
    #                         = -4.556965564807075 / cell              

    # K pt calc
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
Beispiel #33
0
def test_diamond_He():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    He = bulk('He', 'diamond', a=3.5)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(He)
    cell.h=He.cell.T

    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    # cell.pseudo = 'gth-pade'
    cell.gs=np.array([15,15,15])
    cell.verbose=7
    cell.build(None,None)

    # replicate cell NxNxN
    repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    mf = pbcdft.RKS(repcell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    # 1x1x1 Gamma -4.59565988176
    # 2x2x2 Gamma [10x10x10 grid] -36.4239485658445
    #                          =  -4.552993570730562 / cell          
    #             [20x20x20 grid] -4.55312928715 / cell
    #             
    # 3x3x3 Gamma [15x15x15 grid] -4.553523556740741 / cell
    # Diamond cubic: -4.56518345190625
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((3,3,3))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    kmf.scf()
Beispiel #34
0
def test_diamond_He():
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, get_bandpath
    He = bulk('He', 'diamond', a=3.5)

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(He)
    cell.h=He.cell

    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    # cell.pseudo = 'gth-pade'
    cell.gs=np.array([15,15,15])
    cell.verbose=7
    cell.build(None,None)

    # replicate cell NxNxN
    repcell = pyscf.pbc.tools.replicate_cell(cell, (2,2,2))
    mf = pbcdft.RKS(repcell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    # 1x1x1 Gamma -4.59565988176
    # 2x2x2 Gamma [10x10x10 grid] -36.4239485658445
    #                          =  -4.552993570730562 / cell          
    #             [20x20x20 grid] -4.55312928715 / cell
    #             
    # 3x3x3 Gamma [15x15x15 grid] -4.553523556740741 / cell
    # Diamond cubic: -4.56518345190625
    
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((3,3,3))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    kmf.scf()
Beispiel #35
0
def test_cubic_diamond_He():
    """
    Take ASE Diamond structure, input into PySCF and run
    """
    ase_atom=Diamond(symbol='He', latticeconstant=3.5)
    print ase_atom.get_volume()

    cell = pbcgto.Cell()
    cell.atom=pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h=ase_atom.cell
    cell.basis = {"He" : [[0, (1.0, 1.0)], [0, (0.8, 1.0)]] }

    cell.gs = np.array([15,15,15])
    # cell.verbose = 7
    cell.build(None, None)
    mf = pbcdft.RKS(cell)
    mf.analytic_int=False
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic: -18.2278622592408

    mf = pbcdft.RKS(cell)
    mf.analytic_int=True
    mf.xc = 'lda,vwn'
    print mf.scf()
    # Diamond cubic (analytic): -18.2278622592283
    #                         = -4.556965564807075 / cell              

    # K pt calc
    scaled_kpts=ase.dft.kpoints.monkhorst_pack((2,2,2))
    abs_kpts=cell.get_abs_kpts(scaled_kpts)

    kmf = pyscf.pbc.scf.kscf.KRKS(cell, abs_kpts)
    kmf.analytic_int=False
    kmf.xc = 'lda,vwn'
    print kmf.scf()
Beispiel #36
0
import pyscf.pbc.tools.pyscf_ase as pyscf_ase
import pyscf.pbc.gto as pbcgto
import pyscf.pbc.dft as pbcdft

import matplotlib.pyplot as plt

from ase.lattice import bulk
from ase.dft.kpoints import special_points, get_bandpath

c = bulk('C', 'diamond', a=3.5668)
print(c.get_volume())

cell = pbcgto.Cell()
cell.atom = pyscf_ase.ase_atoms_to_pyscf(c)
cell.a = c.cell

cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.verbose = 5
cell.build(None,None)

points = special_points['fcc']
G = points['G']
X = points['X']
W = points['W']
K = points['K']
L = points['L']
band_kpts, kpath, sp_points = get_bandpath([L, G, X, W, K, G], c.cell, npoints=50)
band_kpts = cell.get_abs_kpts(band_kpts)

#
Beispiel #37
0
def plot_bands(scftype, basis, ngs, nmp=None):
    # Set-up the unit cell
    from ase.lattice import bulk
    from ase.dft.kpoints import ibz_points, kpoint_convert, get_bandpath
    ase_atom = bulk('C', 'diamond', a=3.5668*ANG2BOHR)
    print "Cell volume =", ase_atom.get_volume(), "Bohr^3"

    # Set-up the band-path via special points
    points = ibz_points['fcc']
    G = points['Gamma']
    X = points['X']
    W = points['W']
    K = points['K']
    L = points['L']
    band_kpts, x, X = get_bandpath([L, G, X, W, K, G], ase_atom.cell, npoints=30)
    abs_kpts = kpoint_convert(ase_atom.cell, skpts_kc=band_kpts) 

    # Build the cell
    cell = pbcgto.Cell()
    cell.unit = 'B'
    cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
    cell.h = ase_atom.cell
    cell.basis = 'gth-%s'%(basis)
    #cell.basis = 'gth-szv'
    #cell.basis = 'gth-dzvp'
    cell.pseudo = 'gth-pade'
    cell.gs = np.array([ngs,ngs,ngs])
    cell.verbose = 7
    cell.build(None,None)

    # Perform the gamma-point SCF
    if scftype == 'dft':
        mf = pbcdft.RKS(cell)
        mf.xc = 'lda,vwn'
    elif scftype == 'hf':
        mf = pbchf.RHF(cell, exxdiv=None)
    else: 
        scaled_mp_kpts = ase.dft.kpoints.monkhorst_pack((nmp,nmp,nmp))
        abs_mp_kpts = cell.get_abs_kpts(scaled_mp_kpts)
        if scftype == 'kdft':
            mf = pbcdft.KRKS(cell, abs_mp_kpts)
            mf.xc = 'lda,vwn'
        else:
            mf = pbchf.KRHF(cell, abs_mp_kpts, exxdiv='vcut_sph')

    mf.analytic_int = False
    mf.scf()
    print "SCF evals =", mf.mo_energy

    # Proceed along k-point band-path
    e_kn = []
    efermi = -99
    for kpt in abs_kpts:
        e, c = mf.get_bands(kpt)
        print kpt, e
        e_kn.append(e)
        if e[4-1] > efermi:
            efermi = e[4-1]
    for k, ek in enumerate(e_kn):
        e_kn[k] = ek-efermi

    # Write the bands to stdout 
    f = open('bands_%s_%s_%d_%d.dat'%(scftype,basis,ngs,nmp),'w')
    f.write("# Special points:\n")
    for point, label in zip(X,['L', 'G', 'X', 'W', 'K', 'G']):
        f.write("# %0.6f %s\n"%(point,label))
    for kk, ek in zip(x, e_kn):
        f.write("%0.6f "%(kk))
        for ekn in ek:
            f.write("%0.6f "%(ekn))
        f.write("\n")
    f.close()

    # Plot the band structure via matplotlib
    emin = -1.0
    emax = 1.0
    plt.figure(figsize=(8, 4))
    nbands = cell.nao_nr()
    for n in range(nbands):
        plt.plot(x, [e_kn[i][n] for i in range(len(x))])
    for p in X:
        plt.plot([p, p], [emin, emax], 'k-')
    plt.plot([0, X[-1]], [0, 0], 'k-')
    plt.xticks(X, ['$%s$' % n for n in ['L', r'\Gamma', 'X', 'W', 'K', r'\Gamma']])
    plt.axis(xmin=0, xmax=X[-1], ymin=emin, ymax=emax)
    plt.xlabel('k-vector')
    plt.ylabel('Energy [au]')

    #plt.show()
    if nmp is None:
        plt.savefig('bands_%s_%s_%d.png'%(scftype,basis,ngs))
    else:
        plt.savefig('bands_%s_%s_%d_%d.png'%(scftype,basis,ngs,nmp))
Beispiel #38
0
"""
Take ASE Diamond structure, input into PySCF and run
"""

import numpy as np
import pyscf.pbc.gto as pbcgto
import pyscf.pbc.dft as pbcdft
from pyscf.pbc.tools import pyscf_ase

import ase
import ase.lattice
from ase.lattice.cubic import Diamond

ase_atom = Diamond(symbol='C', latticeconstant=3.5668)
print(ase_atom.get_volume())

cell = pbcgto.Cell()
cell.verbose = 5
cell.atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom)
cell.a = ase_atom.cell
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.build()

mf = pbcdft.RKS(cell)

mf.xc = 'lda,vwn'

print(mf.kernel())  # [10,10,10]: -44.8811199336
Beispiel #39
0
#!/usr/bin/env python

'''
CCSD with K-point sampling
'''

from pyscf.pbc import gto, scf, cc
from pyscf.pbc.tools import pyscf_ase

from ase.lattice import bulk
ase_atom = bulk('C', 'diamond', a=3.5668)

cell = gto.M(
    h = ase_atom.cell,
    atom = pyscf_ase.ase_atoms_to_pyscf(ase_atom),
    basis = 'gth-szv'
    pseudo = 'gth-pade'
    gs = [10]*3,
    verbose = 4,
)

nk = [2,2,2]
kpts = cell.make_kpts(nk)

#
# Running HF
#
kmf = scf.KRHF(cell, kpts, exxdiv=None)
ehf = kmf.kernel()

#