def test_ERIS(self): mycc = rccsd.RCCSD(mf) numpy.random.seed(1) mo_coeff = numpy.random.random(mf.mo_coeff.shape) eris = rccsd._make_eris_incore(mycc, mo_coeff) self.assertAlmostEqual(lib.finger(eris.oooo), 4.963884938282539, 11) self.assertAlmostEqual(lib.finger(eris.ovoo), -1.362368189698315, 11) self.assertAlmostEqual(lib.finger(eris.ovov), 125.815506844421580, 11) self.assertAlmostEqual(lib.finger(eris.oovv), 55.123681017639463, 11) self.assertAlmostEqual(lib.finger(eris.ovvo), 133.480835278982620, 11) self.assertAlmostEqual(lib.finger(eris.ovvv), 95.756230114113222, 11) self.assertAlmostEqual(lib.finger(eris.vvvv), -10.450387490987071, 11) ccsd.MEMORYMIN, bak = 0, ccsd.MEMORYMIN mycc.max_memory = 0 eris1 = mycc.ao2mo(mo_coeff) ccsd.MEMORYMIN = bak self.assertAlmostEqual( abs(numpy.array(eris1.oooo) - eris.oooo).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.ovoo) - eris.ovoo).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.ovov) - eris.ovov).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.oovv) - eris.oovv).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.ovvo) - eris.ovvo).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.ovvv) - eris.ovvv).max(), 0, 11) self.assertAlmostEqual( abs(numpy.array(eris1.vvvv) - eris.vvvv).max(), 0, 11) # Testing the complex MO integrals def ao2mofn(mos): if isinstance(mos, numpy.ndarray) and mos.ndim == 2: mos = [mos] * 4 nmos = [mo.shape[1] for mo in mos] eri_mo = ao2mo.kernel(mf._eri, mos, compact=False).reshape(nmos) return eri_mo * 1j eris1 = rccsd._make_eris_incore(mycc, mo_coeff, ao2mofn=ao2mofn) self.assertAlmostEqual(abs(eris1.oooo.imag - eris.oooo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovoo.imag - eris.ovoo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovov.imag - eris.ovov).max(), 0, 11) self.assertAlmostEqual(abs(eris1.oovv.imag - eris.oovv).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovvo.imag - eris.ovvo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovvv.imag - eris.ovvv).max(), 0, 11) self.assertAlmostEqual(abs(eris1.vvvv.imag - eris.vvvv).max(), 0, 11)
def test_ERIS(self): mycc = rccsd.RCCSD(mf) numpy.random.seed(1) mo_coeff = numpy.random.random(mf.mo_coeff.shape) eris = rccsd._make_eris_incore(mycc, mo_coeff) self.assertAlmostEqual(lib.finger(eris.oooo), 4.963884938282539, 11) self.assertAlmostEqual(lib.finger(eris.ovoo), -1.362368189698315, 11) self.assertAlmostEqual(lib.finger(eris.ovov),125.815506844421580, 11) self.assertAlmostEqual(lib.finger(eris.oovv), 55.123681017639463, 11) self.assertAlmostEqual(lib.finger(eris.ovvo),133.480835278982620, 11) self.assertAlmostEqual(lib.finger(eris.ovvv), 95.756230114113222, 11) self.assertAlmostEqual(lib.finger(eris.vvvv),-10.450387490987071, 11) ccsd.MEMORYMIN, bak = 0, ccsd.MEMORYMIN mycc.max_memory = 0 eris1 = mycc.ao2mo(mo_coeff) ccsd.MEMORYMIN = bak self.assertAlmostEqual(abs(numpy.array(eris1.oooo)-eris.oooo).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.ovoo)-eris.ovoo).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.ovov)-eris.ovov).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.oovv)-eris.oovv).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.ovvo)-eris.ovvo).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.ovvv)-eris.ovvv).max(), 0, 11) self.assertAlmostEqual(abs(numpy.array(eris1.vvvv)-eris.vvvv).max(), 0, 11) # Testing the complex MO integrals def ao2mofn(mos): if isinstance(mos, numpy.ndarray) and mos.ndim == 2: mos = [mos]*4 nmos = [mo.shape[1] for mo in mos] eri_mo = ao2mo.kernel(mf._eri, mos, compact=False).reshape(nmos) return eri_mo * 1j eris1 = rccsd._make_eris_incore(mycc, mo_coeff, ao2mofn=ao2mofn) self.assertAlmostEqual(abs(eris1.oooo.imag-eris.oooo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovoo.imag-eris.ovoo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovov.imag-eris.ovov).max(), 0, 11) self.assertAlmostEqual(abs(eris1.oovv.imag-eris.oovv).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovvo.imag-eris.ovvo).max(), 0, 11) self.assertAlmostEqual(abs(eris1.ovvv.imag-eris.ovvv).max(), 0, 11) self.assertAlmostEqual(abs(eris1.vvvv.imag-eris.vvvv).max(), 0, 11)
def ao2mo(self, mo_coeff=None): from pyscf.cc import rccsd from pyscf.pbc import tools from pyscf.pbc.cc.ccsd import _adjust_occ ao2mofn = mp.mp2._gen_ao2mofn(self._scf) with lib.temporary_env(self._scf, exxdiv=None): eris = rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn) if mo_coeff is self._scf.mo_coeff: eris.mo_energy = self._scf.mo_energy[self.get_frozen_mask()] else: madelung = tools.madelung(self._scf.cell, self._scf.kpt) eris.mo_energy = _adjust_occ(eris.mo_energy, eris.nocc, -madelung) return eris
def ao2mo(self, mo_coeff=None): from pyscf.cc import rccsd from pyscf.pbc import tools from pyscf.pbc.cc.ccsd import _adjust_occ ao2mofn = mp.mp2._gen_ao2mofn(self._scf) with lib.temporary_env(self._scf, exxdiv=None): eris = rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn) if mo_coeff is self._scf.mo_coeff: eris.mo_energy = self._scf.mo_energy[self.get_frozen_mask()] else: madelung = tools.madelung(self._scf.cell, self._scf.kpt) eris.mo_energy = _adjust_occ(eris.mo_energy, eris.nocc, -madelung) return eris
def ao2mo(self, mo_coeff=None): from pyscf.pbc import tools ao2mofn = mp.mp2._gen_ao2mofn(self._scf) # _scf.exxdiv affects eris.fock. HF exchange correction should be # excluded from the Fock matrix. with lib.temporary_env(self._scf, exxdiv=None): eris = rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn) # eris.mo_energy so far is just the diagonal part of the Fock matrix # without the exxdiv treatment. Here to add the exchange correction to # get better orbital energies. It is important for the low-dimension # systems since their occupied and the virtual orbital energies may # overlap which may lead to numerical issue in the CCSD iterations. if mo_coeff is self._scf.mo_coeff: eris.mo_energy = self._scf.mo_energy[self.get_frozen_mask()] else: # Add the HFX correction of Ewald probe charge method. # FIXME: Whether to add this correction for other exxdiv treatments? # Without the correction, MP2 energy may be largely off the # correct value. madelung = tools.madelung(self._scf.cell, self._scf.kpt) eris.mo_energy = _adjust_occ(eris.mo_energy, eris.nocc, -madelung) return eris
def ao2mo(self, mo_coeff=None): from pyscf.pbc import tools ao2mofn = mp.mp2._gen_ao2mofn(self._scf) # _scf.exxdiv affects eris.fock. HF exchange correction should be # excluded from the Fock matrix. with lib.temporary_env(self._scf, exxdiv=None): eris = rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn) # eris.mo_energy so far is just the diagonal part of the Fock matrix # without the exxdiv treatment. Here to add the exchange correction to # get better orbital energies. It is important for the low-dimension # systems since their occupied and the virtual orbital energies may # overlap which may lead to numerical issue in the CCSD iterations. #if mo_coeff is self._scf.mo_coeff: # eris.mo_energy = self._scf.mo_energy[self.get_frozen_mask()] #else: # # Add the HFX correction of Ewald probe charge method. # # FIXME: Whether to add this correction for other exxdiv treatments? # # Without the correction, MP2 energy may be largely off the # # correct value. madelung = tools.madelung(self._scf.cell, self._scf.kpt) eris.mo_energy = _adjust_occ(eris.mo_energy, eris.nocc, -madelung) return eris
def ao2mo(self, mo_coeff=None): from pyscf.cc import rccsd ao2mofn = mp.mp2._gen_ao2mofn(self._scf) return rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn)
def ao2mo(self, mo_coeff=None): ao2mofn = mp.mp2._gen_ao2mofn(self._scf) return rccsd._make_eris_incore(self, mo_coeff, ao2mofn=ao2mofn)