Beispiel #1
0
    def test_h4_fcc_k2(self):
        '''Metallic hydrogen fcc lattice.  Checks versus a corresponding
        supercell calculation.

        NOTE: different versions of the davidson may converge to a different
        solution for the k-point IP/EA eom.  If you're getting the wrong
        root, check to see if it's contained in the supercell set of
        eigenvalues.'''
        cell = pbcgto.Cell()
        cell.atom = [['H', (0.000000000, 0.000000000, 0.000000000)],
                     ['H', (0.000000000, 0.500000000, 0.250000000)],
                     ['H', (0.500000000, 0.500000000, 0.500000000)],
                     ['H', (0.500000000, 0.000000000, 0.750000000)]]
        cell.unit = 'Bohr'
        cell.a = [[1., 0., 0.], [0., 1., 0], [0, 0, 2.2]]
        cell.verbose = 7
        cell.spin = 0
        cell.charge = 0
        cell.basis = [
            [0, [1.0, 1]],
        ]
        cell.pseudo = 'gth-pade'
        cell.output = '/dev/null'
        #cell.max_memory = 1000
        for i in range(len(cell.atom)):
            cell.atom[i][1] = tuple(
                np.dot(np.array(cell.atom[i][1]), np.array(cell.a)))
        cell.build()

        nmp = [2, 1, 1]

        kmf = pbcscf.KRHF(cell)
        kmf.kpts = cell.make_kpts(nmp, scaled_center=[0.0, 0.0, 0.0])
        e = kmf.kernel()

        mycc = pbcc.KCCSD(kmf)
        ekccsd, _, _ = mycc.kernel()
        self.assertAlmostEqual(ekccsd, -0.06146759560406628, 6)

        # Getting more roots than 1 is difficult
        e = mycc.eaccsd(nroots=1, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], 5.079427283440857, 6)
        e = mycc.eaccsd(nroots=1, koopmans=False, kptlist=(1, ))[0]
        self.assertAlmostEqual(e[0][0], 4.183328878177331, 6)

        e = mycc.ipccsd(nroots=1, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], -3.471710821544506, 6)
        e = mycc.ipccsd(nroots=1, koopmans=False, kptlist=(1, ))[0]
        self.assertAlmostEqual(e[0][0], -4.272015727359054, 6)

        # Start of supercell calculations
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nmp)
        supcell.build()
        mf = pbcscf.KRHF(supcell)
        e = mf.kernel()

        myscc = pbcc.KCCSD(mf)
        eccsd, _, _ = myscc.kernel()
        eccsd /= np.prod(nmp)
        self.assertAlmostEqual(eccsd, -0.06146759560406628, 6)

        e = myscc.eaccsd(nroots=4, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], 4.183328873793568, 6)
        self.assertAlmostEqual(e[0][1], 4.225034294249784, 6)
        self.assertAlmostEqual(e[0][2], 5.068962665511664, 6)
        self.assertAlmostEqual(e[0][3], 5.07942727935064, 6)

        e = myscc.ipccsd(nroots=4, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], -4.272015724869052, 6)
        self.assertAlmostEqual(e[0][1], -4.254298274388934, 6)
        self.assertAlmostEqual(e[0][2], -3.471710821688812, 6)
        self.assertAlmostEqual(e[0][3], -3.462817764320668, 6)
Beispiel #2
0
    def test_h4_fcc_k2_frozen(self):
        '''Metallic hydrogen fcc lattice with frozen lowest lying occupied
        and highest lying virtual orbitals.  Checks versus a corresponding
        supercell calculation.

        NOTE: different versions of the davidson may converge to a different
        solution for the k-point IP/EA eom.  If you're getting the wrong
        root, check to see if it's contained in the supercell set of
        eigenvalues.'''
        cell = pbcgto.Cell()
        cell.atom = [['H', (0.000000000, 0.000000000, 0.000000000)],
                     ['H', (0.000000000, 0.500000000, 0.250000000)],
                     ['H', (0.500000000, 0.500000000, 0.500000000)],
                     ['H', (0.500000000, 0.000000000, 0.750000000)]]
        cell.unit = 'Bohr'
        cell.a = [[1., 0., 0.], [0., 1., 0], [0, 0, 2.2]]
        cell.verbose = 7
        cell.spin = 0
        cell.charge = 0
        cell.basis = [
            [0, [1.0, 1]],
        ]
        cell.pseudo = 'gth-pade'
        cell.output = '/dev/null'
        #cell.max_memory = 1000
        for i in range(len(cell.atom)):
            cell.atom[i][1] = tuple(
                np.dot(np.array(cell.atom[i][1]), np.array(cell.a)))
        cell.build()

        nmp = [2, 1, 1]

        kmf = pbcscf.KRHF(cell)
        kmf.kpts = cell.make_kpts(nmp, scaled_center=[0.0, 0.0, 0.0])
        e = kmf.kernel()

        frozen = [[0, 3], []]
        mycc = pbcc.KCCSD(kmf, frozen=frozen)
        ekccsd, _, _ = mycc.kernel()
        self.assertAlmostEqual(ekccsd, -0.04683399814247455, 6)

        # Getting more roots than 1 is difficult
        e = mycc.eaccsd(nroots=1, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], 5.060562738181741, 6)
        e = mycc.eaccsd(nroots=1, koopmans=False, kptlist=(1, ))[0]
        self.assertAlmostEqual(e[0][0], 4.188511644938458, 6)

        e = mycc.ipccsd(nroots=1, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], -3.477663551987023, 6)
        e = mycc.ipccsd(nroots=1, koopmans=False, kptlist=(1, ))[0]
        self.assertAlmostEqual(e[0][0], -4.23523412155825, 6)

        # Start of supercell calculations
        from pyscf.pbc.tools.pbc import super_cell
        supcell = super_cell(cell, nmp)
        supcell.build()
        mf = pbcscf.KRHF(supcell)
        e = mf.kernel()

        myscc = pbcc.KCCSD(mf, frozen=[0, 7])
        eccsd, _, _ = myscc.kernel()
        eccsd /= np.prod(nmp)
        self.assertAlmostEqual(eccsd, -0.04683401678904569, 6)

        e = myscc.eaccsd(nroots=4, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], 4.188511680212755, 6)
        self.assertAlmostEqual(e[0][1], 4.205924087610756, 6)
        self.assertAlmostEqual(e[0][2], 5.060562771978923, 6)
        self.assertAlmostEqual(e[0][3], 5.077249823137741, 6)

        e = myscc.ipccsd(nroots=4, koopmans=False, kptlist=(0, ))[0]
        self.assertAlmostEqual(e[0][0], -4.261818242746091, 6)
        self.assertAlmostEqual(e[0][1], -4.235233956876479, 6)
        self.assertAlmostEqual(e[0][2], -3.477663568390151, 6)
        self.assertAlmostEqual(e[0][3], -3.459133332687474, 6)
Beispiel #3
0
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(
    a=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()

#
# Running CCSD
#
kcc = cc.KCCSD(kmf)
ecc, t1, t2 = kcc.kernel()
print("cc energy (per unit cell) = %.17g" % ecc)
Beispiel #4
0
cell.spin = 0
cell.charge = 0
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
for i in range(len(cell.atom)):
    cell.atom[i][1] = tuple(np.dot(np.array(cell.atom[i][1]),
                                   np.array(cell.a)))
cell.build()

nmp = [2, 1, 1]

kmf = pbcscf.KRHF(cell)
kmf.kpts = cell.make_kpts(nmp, scaled_center=[0.0, 0.0, 0.0])
e = kmf.kernel()  # 2.30510338236481

mycc = pbcc.KCCSD(kmf)
eris = mycc.ao2mo(kmf.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(mycc.nkpts)]
print('\nCCSD energy w/o level shift and MP2 initial guess:'
      )  # 0.02417522810234485
ekccsd, t1, t2 = mycc.kernel(eris=eris)

# Use a level shift with a level shift equal to the Madelung
# constant for this system.  Using the previous t1/t2 as an initial
# guess, we see that these amplitudes still solve the CCSD amplitude
# equations.


def _adjust_occ(mo_energy, nocc, shift):
    '''Modify occupied orbital energy'''
    mo_energy = mo_energy.copy()
Beispiel #5
0
def run_kccsd(mf):
    cc = pbccc.KCCSD(mf)
    cc.verbose = 7
    cc.ccsd()
    return cc
Beispiel #6
0
    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)
kpts = cell.make_kpts(k_points)

mf = scf.KRHF(cell)
mf.with_df = getattr(df, density_fit)(cell)
if density_fit == "gdf" or density_fit == "mdf":
    mf.with_df.auxbasis = aux_basis_set
mf.kpts = kpts
mf.kernel()

my_cc = cc.KCCSD(mf)
my_cc.kernel()
Beispiel #7
0
    # scaled_center = np.random.rand(3)

    log = logger.Logger(cell.stdout, 6)

    for kmesh in ([
            1,
            1,
            1,
    ], [2, 1, 1]):
        kpts = cell.make_kpts(kmesh, scaled_center=scaled_center)
        log.info("kmesh= %s", kmesh)
        log.info("kpts = %s", kpts)

        from pyscf.pbc import scf, mp, cc
        mf = scf.KRHF(cell, kpts=kpts).rs_density_fit()
        mf.kernel()

        mf2 = scf.KRHF(cell, kpts=kpts).density_fit()
        mf2.kernel()
        log.info("HF/GDF   energy   : % .10f", mf2.e_tot)
        log.info("HF/RSGDF energy   : % .10f", mf.e_tot)
        log.info("difference        : % .3g", (mf.e_tot - mf2.e_tot))

        mc = cc.KCCSD(mf)
        mc.kernel()
        mc2 = cc.KCCSD(mf2)
        mc2.kernel()
        log.info("CCSD/GDF   energy : % .10f", mc2.e_corr)
        log.info("CCSD/RSGDF energy : % .10f", mc.e_corr)
        log.info("difference        : % .3g\n", (mc.e_corr - mc2.e_corr))