コード例 #1
0
ファイル: PyscfToQmcpack.py プロジェクト: camelto2/qmcpack
  def get_phase(cell, kpts, kmesh=[]):
        '''
        The unitary transformation that transforms the supercell basis k-mesh
        adapted basis.
        '''
 
        latt_vec = cell.lattice_vectors()
        if kmesh is None:
            # Guess kmesh
            scaled_k = cell.get_scaled_kpts(kpts).round(8)
            kmesh = (len(numpy.unique(scaled_k[:,0])),
                     len(numpy.unique(scaled_k[:,1])),
                     len(numpy.unique(scaled_k[:,2])))
 
        R_rel_a = numpy.arange(kmesh[0])
        R_rel_b = numpy.arange(kmesh[1])
        R_rel_c = numpy.arange(kmesh[2])


        R_vec_rel = lib.cartesian_prod((R_rel_a, R_rel_b, R_rel_c))
        R_vec_abs = numpy.einsum('nu, uv -> nv', R_vec_rel, latt_vec)
 
        NR = len(R_vec_abs)
        phase = numpy.exp(1j*numpy.einsum('Ru, ku -> Rk', R_vec_abs, kpts))
        phase /= numpy.sqrt(NR)  # normalization in supercell
 
        # R_rel_mesh has to be construct exactly same to the Ts in super_cell function
        scell = tools.super_cell(cell, kmesh)
        return scell, phase
コード例 #2
0
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
コード例 #3
0
ファイル: k2gamma.py プロジェクト: chrinide/pyscf
def get_phase(cell, kpts, kmesh=None):
    '''
    The unitary transformation that transforms the supercell basis k-mesh
    adapted basis.
    '''

    latt_vec = cell.lattice_vectors()
    if kmesh is None:
        # Guess kmesh
        scaled_k = cell.get_scaled_kpts(kpts).round(8)
        kmesh = (len(np.unique(scaled_k[:,0])),
                 len(np.unique(scaled_k[:,1])),
                 len(np.unique(scaled_k[:,2])))

    R_rel_a = np.arange(kmesh[0])
    R_rel_b = np.arange(kmesh[1])
    R_rel_c = np.arange(kmesh[2])
    R_vec_rel = lib.cartesian_prod((R_rel_a, R_rel_b, R_rel_c))
    R_vec_abs = np.einsum('nu, uv -> nv', R_vec_rel, latt_vec)

    NR = len(R_vec_abs)
    phase = np.exp(1j*np.einsum('Ru, ku -> Rk', R_vec_abs, kpts))
    phase /= np.sqrt(NR)  # normalization in supercell

    # R_rel_mesh has to be construct exactly same to the Ts in super_cell function
    scell = tools.super_cell(cell, kmesh)
    return scell, phase
コード例 #4
0
ファイル: test_pbc.py プロジェクト: NuturesH/pyscf-1
 def test_super_cell(self):
     numpy.random.seed(2)
     cl1 = pbcgto.M(a = numpy.random.random((3,3))*3,
                    mesh = [3]*3,
                    atom ='''He .1 .0 .0''',
                    basis = 'ccpvdz')
     cl2 = tools.super_cell(cl1, [2,3,4])
     self.assertAlmostEqual(lib.finger(cl2.atom_coords()), -18.946080642714836, 9)
コード例 #5
0
ファイル: test_gamma_vs_ks.py プロジェクト: chrinide/pyscf
    def test_gamma_vs_ks_high_cost(self):
        mf = pdft.KRKS(cell)
        mf.kpts = cell.make_kpts([1,1,3])
        ek = mf.kernel()

        scell = ptools.super_cell(cell, [1,1,3])
        scell.mesh = [25,25,73]
        mf = pdft.RKS(scell)
        eg = mf.kernel()
        self.assertAlmostEqual(ek, eg/3, 5)
コード例 #6
0
    def test_gamma_vs_ks(self):
        mf = pdft.KRKS(cell)
        mf.kpts = cell.make_kpts([1, 1, 3])
        ek = mf.kernel()

        scell = ptools.super_cell(cell, [1, 1, 3])
        scell.gs = [12, 12, 36]
        mf = pdft.RKS(scell)
        eg = mf.kernel()
        self.assertAlmostEqual(ek, eg / 3, 5)
コード例 #7
0
ファイル: test_gamma_vs_ks.py プロジェクト: zzy2014/pyscf
    def test_gamma_vs_ks_high_cost(self):
        mf = pdft.KRKS(cell)
        mf.kpts = cell.make_kpts([1, 1, 3])
        ek = mf.kernel()

        scell = ptools.super_cell(cell, [1, 1, 3])
        scell.mesh = [25, 25, 73]
        mf = pdft.RKS(scell)
        eg = mf.kernel()
        self.assertAlmostEqual(ek, eg / 3, 5)
コード例 #8
0
ファイル: slaterpbc.py プロジェクト: sapatha2/pyqmc
def generate_test_inputs():
    import pyqmc
    from pyqmc.coord import PeriodicConfigs
    from pyscf.pbc import gto, scf
    from pyscf.pbc.dft.multigrid import multigrid
    from pyscf.pbc import tools
    from pyscf import lib

    from_chkfile = True

    if from_chkfile:

        def loadchkfile(chkfile):
            cell = gto.cell.loads(lib.chkfile.load(chkfile, "mol"))
            kpts = cell.make_kpts([1, 1, 1])
            mf = scf.KRKS(cell, kpts)
            mf.__dict__.update(lib.chkfile.load(chkfile, "scf"))
            return cell, mf

        cell1, mf1 = loadchkfile("mf1.chkfile")
        cell2, mf2 = loadchkfile("mf2.chkfile")
    else:
        L = 4
        cell2 = gto.M(
            atom="""H     {0}      {0}      {0}                
                      H     {1}      {1}      {1}""".format(0.0, L * 0.25),
            basis="sto-3g",
            a=np.eye(3) * L,
            spin=0,
            unit="bohr",
        )

        print("Primitive cell")
        kpts = cell2.make_kpts((2, 2, 2))
        mf2 = scf.KRKS(cell2, kpts)
        mf2.xc = "pbe"
        mf2.chkfile = "mf2.chkfile"
        mf2 = mf2.run()

        print("Supercell")
        cell1 = tools.super_cell(cell2, [2, 2, 2])
        kpts = [[0, 0, 0]]
        mf1 = scf.KRKS(cell1, kpts)
        mf1.xc = "pbe"
        mf1.chkfile = "mf1.chkfile"
        mf1 = mf1.run()

    # wf1 = pyqmc.PySCFSlaterUHF(cell1, mf1)
    wf1 = PySCFSlaterPBC(cell1, mf1, supercell=1 * np.eye(3))
    wf2 = PySCFSlaterPBC(cell2, mf2, supercell=2 * np.eye(3))

    configs = pyqmc.initial_guess(cell1, 10, 0.1)

    return wf1, wf2, configs
コード例 #9
0
ファイル: test_pbc.py プロジェクト: NuturesH/pyscf-1
 def test_madelung(self):
     cell = pbcgto.Cell()
     cell.atom = 'He 0 0 0'
     cell.a = '''0.      1.7834  1.7834
                 1.7834  0.      1.7834
                 1.7834  1.7834  0.    '''
     cell.build()
     scell = tools.super_cell(cell, [2,3,5])
     mad0 = tools.madelung(scell, [0,0,0])
     kpts = cell.make_kpts([2,3,5])
     mad1 = tools.madelung(cell, kpts)
     self.assertAlmostEqual(mad0-mad1, 0, 9)
コード例 #10
0
def get_phase(cell, kpts, kmesh=None):
    '''
    The unitary transformation that transforms the supercell basis k-mesh
    adapted basis.
    '''
    if kmesh is None:
        kmesh = kpts_to_kmesh(cell, kpts)
    R_vec_abs = translation_vectors_for_kmesh(cell, kmesh)

    NR = len(R_vec_abs)
    phase = np.exp(1j * np.einsum('Ru, ku -> Rk', R_vec_abs, kpts))
    phase /= np.sqrt(NR)  # normalization in supercell

    # R_rel_mesh has to be construct exactly same to the Ts in super_cell function
    scell = tools.super_cell(cell, kmesh)
    return scell, phase
コード例 #11
0
ファイル: PyscfToQmcpack.py プロジェクト: kovalp/qmcpack
    def get_supercell(cell, kmesh=[]):
        latt_vec = cell.lattice_vectors()
        if len(kmesh) == 0:
            # Guess kmesh
            scaled_k = cell.get_scaled_kpts(kpts).round(8)
            kmesh = (len(numpy.unique(scaled_k[:, 0])),
                     len(numpy.unique(scaled_k[:, 1])),
                     len(numpy.unique(scaled_k[:, 2])))

        R_rel_a = numpy.arange(kmesh[0])
        R_rel_b = numpy.arange(kmesh[1])
        R_rel_c = numpy.arange(kmesh[2])
        R_vec_rel = lib.cartesian_prod((R_rel_a, R_rel_b, R_rel_c))
        R_vec_abs = numpy.einsum('nu, uv -> nv', R_vec_rel, latt_vec)

        # R_rel_mesh has to be construct exactly same to the Ts in super_cell function
        scell = tools.super_cell(cell, kmesh)
        return scell, kmesh
コード例 #12
0
ファイル: 31-low_dimensional_pbc.py プロジェクト: xlzan/pyscf
           verbose = 0,
           basis='sto3g')
mf = pbchf.KRHF(cell)
mf.with_df = pdf.AFTDF(cell)
mf.kpts = cell.make_kpts([4,1,1])
e.append(mf.kernel())

mf = pbchf.KRHF(cell).density_fit(auxbasis='weigend')
mf.kpts = cell.make_kpts([4,1,1])
e.append(mf.kernel())

mf = pbchf.KRHF(cell).mix_density_fit(auxbasis='weigend')
mf.kpts = cell.make_kpts([4,1,1])
e.append(mf.kernel())

mol = tools.super_cell(cell, [4,1,1]).to_mol()
mf = scf.RHF(mol)
e.append(mf.kernel()/4)

print('1D:  AFT      DF       MDF       super-mole')
print(e)

##################################################
#
# 2D PBC
#
##################################################

e = []
L = 4
cell = pbcgto.Cell()
コード例 #13
0
e = []
L = 4
cell = pbcgto.Cell()
cell.build(unit = 'B',
           a = [[L,0,0],[0,L,0],[0,0,8.]],
           mesh = [10,10,20],
           atom = 'H 0 0 0; H 0 0 1.8',
           dimension=2,
           verbose = 4,
           basis='sto3g')

mf = pbchf.KRHF(cell)
mf.with_df = pdf.AFTDF(cell)
mf.kpts = cell.make_kpts([4,4,1])
e.append(mf.kernel())

mf = pbchf.KRHF(cell, cell.make_kpts([4,4,1]))
mf = mf.density_fit(auxbasis='weigend', with_df=pdf.GDF(cell))
e.append(mf.kernel())

mf = pbchf.KRHF(cell, cell.make_kpts([4,4,1]))
mf = mf.mix_density_fit(auxbasis='weigend', with_df=pdf.MDF(cell))
e.append(mf.kernel())

mol = tools.super_cell(cell, [4,4,1]).to_mol()
mf = scf.RHF(mol)
e.append(mf.kernel()/16)

print(e)
コード例 #14
0
ファイル: dft.py プロジェクト: faraimazh/atomsandbits
lattice_vectors = [
    flat_lattice_vectors[0:3], flat_lattice_vectors[3:6],
    flat_lattice_vectors[6:9]
]
num_frozen_cores = int(
    results.frozen_cores) if results.frozen_cores is not None else 0

sys.argv = [sys.argv[0]]

# -----------------------
#     PYSCF
# -----------------------

cell = gto.M(atom=atomic_coords,
             basis=basis_set,
             spin=spin,
             charge=charge,
             a=lattice_vectors,
             pseudo=pseudo_potential,
             precision=1e-6,
             verbose=5)
mol = tools.super_cell(cell, k_points).to_mol()

my_dft = dft.RKS(mol)
my_dft.xc = functional
if density_fit:
    my_dft.with_df = getattr(df, density_fit)(cell)
if density_fit == "gdf" or density_fit == "mdf":
    my_dft.with_df.auxbasis = aux_basis_set
my_dft.kernel()
コード例 #15
0
ファイル: k2gamma.py プロジェクト: zzy2014/pyscf
    s_k = cell.pbc_intor('int1e_ovlp', kpts=kpts)
    s = scell.pbc_intor('int1e_ovlp')
    s1 = np.einsum('Rk,kij,Sk->RiSj', phase, s_k, phase.conj())
    print(abs(s-s1.reshape(s.shape)).max())

    s = scell.pbc_intor('int1e_ovlp').reshape(NR,nao,NR,nao)
    s1 = np.einsum('Rk,RiSj,Sk->kij', phase.conj(), s, phase)
    print(abs(s1-s_k).max())

    kmf = dft.KRKS(cell, kpts)
    ekpt = kmf.run()

    mf = k2gamma(kmf, kmesh)
    c_g_ao = mf.mo_coeff

    # The following is to check whether the MO is correctly coverted:

    print("Supercell gamma MO in AO basis from conversion:")
    scell = tools.super_cell(cell, kmesh)
    mf_sc = dft.RKS(scell)

    s = mf_sc.get_ovlp()
    mf_sc.run()
    sc_mo = mf_sc.mo_coeff

    nocc = scell.nelectron // 2
    print("Supercell gamma MO from direct calculation:")
    print(np.linalg.det(c_g_ao[:,:nocc].T.conj().dot(s).dot(sc_mo[:,:nocc])))
    print(np.linalg.svd(c_g_ao[:,:nocc].T.conj().dot(s).dot(sc_mo[:,:nocc]))[1])

コード例 #16
0
ファイル: omp_sgx_ps_dm.py プロジェクト: wangya134/sgX
from pyscf.pbc import gto as pbcgto
from pyscf.pbc import tools as pbctools
import time

cell = pbcgto.Cell()

#Molecule
cell.a = [[0., 3.37013733, 3.37013733], [3.37013733, 0., 3.37013733],
          [3.37013733, 3.37013733, 0.]]
cell.atom = """
C 0 0 0
C 1.68506866 1.68506866 1.68506866
"""
cell.build()
cell.verbose = 5
scell = pbctools.super_cell(cell, [1, 1, 4])
mol = gto.Mole()
mol.atom = scell._atom
mol.unit = 'Bohr'
mol.basis = 'ccpvdz'
mol.verbose = 4
mol.build()
#mol.verbose = 6
#, output = '1ewcn.out'
print('basis=', mol.basis, 'nao', mol.nao)
# HF reference with analytical two-electron integrals
mf = scf.RHF(mol)
mf.max_memory = 120000
mf.max_cycle = 200
mf.conv_tol = 2e-5
mf.verbose = 4