def setUpModule(): global cell_n3d, kmf, rand_kmf, rand_kmf1, rand_kmf2 cell_n3d = make_test_cell.test_cell_n3_diffuse() kmf = pbcscf.KRHF(cell_n3d, cell_n3d.make_kpts((1, 1, 2), with_gamma_point=True), exxdiv=None) kmf.conv_tol = 1e-10 kmf.scf() rand_kmf = make_rand_kmf() rand_kmf1 = make_rand_kmf(nkpts=1) rand_kmf2 = make_rand_kmf(nkpts=2)
def test_n3_diffuse(self): self.assertAlmostEqual(kmf.e_tot, -6.1870676561721227, 6) cell = make_test_cell.test_cell_n3_diffuse() nmp = [1, 1, 2] ''' # treating 1*1*2 supercell at gamma point supcell = super_cell(cell,nmp) gmf = scf.UHF(supcell,exxdiv=None) ehf = gmf.kernel() gcc = cc.UCCSD(gmf) gcc.conv_tol=1e-12 gcc.conv_tol_normt=1e-10 gcc.max_cycle=250 ecc, t1, t2 = gcc.kernel() print('UHF energy (supercell) %.7f \n' % (float(ehf)/2.)) print('UCCSD correlation energy (supercell) %.7f \n' % (float(ecc)/2.)) #eom = eom_uccsd.EOMIP(gcc) #e1, v = eom.ipccsd(nroots=2) #eom = eom_uccsd.EOMEA(gcc) #e2, v = eom.eaccsd(nroots=2, koopmans=True) ''' mycc = pbcc.KUCCSD(kmf) mycc.conv_tol = 1e-7 mycc.conv_tol_normt = 1e-7 ecc2, t1, t2 = mycc.kernel() self.assertAlmostEqual(ecc2, -0.0676483711263548, 6) eom = EOMIP(mycc) e1_obt, v = eom.ipccsd(nroots=3, koopmans=True, kptlist=[0]) self.assertAlmostEqual(e1_obt[0][0], -1.148946994550331, 6) self.assertAlmostEqual(e1_obt[0][1], -1.148946994544336, 6) self.assertAlmostEqual(e1_obt[0][2], -1.10881945217663, 6) eom = EOMEA(mycc) e2_obt, v = eom.eaccsd(nroots=3, koopmans=True, kptlist=[0]) self.assertAlmostEqual(e2_obt[0][0], 1.26697897719539, 6) self.assertAlmostEqual(e2_obt[0][1], 1.26697897720534, 6) self.assertAlmostEqual(e2_obt[0][2], 1.278883205460933, 6) eom = EOMIP(mycc) e1_obt, v = eom.ipccsd(nroots=3, koopmans=True, kptlist=[1]) self.assertAlmostEqual(e1_obt[0][0], -0.9074337295664157, 6) self.assertAlmostEqual(e1_obt[0][1], -0.9074337295664148, 6) self.assertAlmostEqual(e1_obt[0][2], -0.9074331791699104, 6) eom = EOMEA(mycc) e2_obt, v = eom.eaccsd(nroots=3, koopmans=True, kptlist=[1]) self.assertAlmostEqual(e2_obt[0][0], 1.227583017460536, 6) self.assertAlmostEqual(e2_obt[0][1], 1.227583017460617, 6) self.assertAlmostEqual(e2_obt[0][2], 1.383037918699404, 6)
def test_n3_diffuse_star(self): '''Tests EOM-CCSD* method.''' cell = make_test_cell.test_cell_n3_diffuse() nmp = [1, 1, 2] ''' # treating 1*1*2 supercell at gamma point supcell = super_cell(cell,nmp) gmf = scf.GHF(supcell,exxdiv=None) ehf = gmf.kernel() gcc = cc.GCCSD(gmf) gcc.conv_tol=1e-12 gcc.conv_tol_normt=1e-10 gcc.max_cycle=250 ecc, t1, t2 = gcc.kernel() print('GHF energy (supercell) %.7f \n' % (float(ehf)/2.)) print('GCCSD correlation energy (supercell) %.7f \n' % (float(ecc)/2.)) #eom = eom_gccsd.EOMIP(gcc) #e1, v = eom.ipccsd_star(nroots=6, koopmans=True) eom = eom_gccsd.EOMEA(gcc) e2, v = eom.eaccsd_star(nroots=9, koopmans=True) ''' ehf2 = kmf.e_tot self.assertAlmostEqual(ehf2, -6.1870676561725695, 6) ecc2 = mycc.e_corr self.assertAlmostEqual(ecc2, -0.0676483716898783, 6) eom = EOMIP(mycc) e1_obt = eom.ipccsd_star(nroots=3, koopmans=True, kptlist=[0], eris=eris) self.assertAlmostEqual(e1_obt[0][0], -1.1452481194582802, 6) self.assertAlmostEqual(e1_obt[0][1], -1.1452481194456137, 6) self.assertAlmostEqual(e1_obt[0][2], -1.1174912094746994, 6) eom = EOMEA(mycc) e1_obt = eom.eaccsd_star(nroots=2, koopmans=True, kptlist=[0, 1], eris=eris) self.assertAlmostEqual(e1_obt[0][0], 1.260627794895514, 6) self.assertAlmostEqual(e1_obt[0][1], 1.260627794895514, 6) self.assertAlmostEqual(e1_obt[1][0], 1.2222607619733454, 6) self.assertAlmostEqual(e1_obt[1][1], 1.2222607619733026, 6)
def test_211_n3(self): cell = make_test_cell.test_cell_n3_diffuse() nk = (2, 1, 1) abs_kpts = cell.make_kpts(nk, wrap_around=True) # GHF calculation kmf = pbcscf.KGHF(cell, abs_kpts, exxdiv=None) kmf.conv_tol = 1e-14 escf = kmf.scf() self.assertAlmostEqual(escf, -6.1870676561726574, 9) # GCCSD calculation cc = pbcc.kccsd.CCSD(kmf) cc.conv_tol = 1e-8 ecc, t1, t2 = cc.kernel() self.assertAlmostEqual(ecc, -0.067648363303697334, 6)
def setUpModule(): global cell, kmf, mycc, eris cell = make_test_cell.test_cell_n3_diffuse() kmf = scf.KRHF(cell, kpts=cell.make_kpts([1, 1, 2], with_gamma_point=True), exxdiv=None) kmf.conv_tol = 1e-10 kmf.conv_tol_grad = 1e-6 kmf.scf() mycc = cc.KGCCSD(kmf) mycc.conv_tol = 1e-7 mycc.conv_tol_normt = 1e-7 mycc.run() eris = mycc.ao2mo() eris.mo_energy = [ eris.fock[ikpt].diagonal().real for ikpt in range(mycc.nkpts) ]
def test_n3_diffuse(self): cell = make_test_cell.test_cell_n3_diffuse() nmp = [1, 1, 2] ''' # treating 1*1*2 supercell at gamma point supcell = super_cell(cell,nmp) gmf = scf.GHF(supcell,exxdiv=None) ehf = gmf.kernel() gcc = cc.GCCSD(gmf) gcc.conv_tol=1e-12 gcc.conv_tol_normt=1e-10 gcc.max_cycle=250 ecc, t1, t2 = gcc.kernel() print('GHF energy (supercell) %.7f \n' % (float(ehf)/2.)) print('GCCSD correlation energy (supercell) %.7f \n' % (float(ecc)/2.)) eom = eom_gccsd.EOMIP(gcc) e1, v = eom.ipccsd(nroots=6) eom = eom_gccsd.EOMEA(gcc) e2, v = eom.eaccsd(nroots=6, left=True, koopmans=True) ''' # Running HF and CCSD with 1x1x2 Monkhorst-Pack k-point mesh ehf2 = kmf.e_tot self.assertAlmostEqual(ehf2, -6.1870676561725695, 6) ecc2 = mycc.e_corr self.assertAlmostEqual(ecc2, -0.0676483716898783, 6) eom = EOMIP(mycc) imds = eom.make_imds(eris=eris) # Basic ipccsd e1_obt, v = eom.ipccsd(nroots=3, left=True, kptlist=[0], imds=imds) self.assertAlmostEqual(e1_obt[0][0], -1.14894700482871, 6) self.assertAlmostEqual(e1_obt[0][1], -1.148947004822481, 6) self.assertAlmostEqual(e1_obt[0][2], -1.108819439453179, 6) # Ensure left is working e1_obt, v = eom.ipccsd(nroots=3, kptlist=[0], imds=imds) self.assertAlmostEqual(e1_obt[0][0], -1.1489469962099519, 6) self.assertAlmostEqual(e1_obt[0][1], -1.1489469961858796, 6) self.assertAlmostEqual(e1_obt[0][2], -1.1088194518036925, 6) # Ensure kptlist behaves correctly e1_obt, v = eom.ipccsd(nroots=3, koopmans=True, kptlist=[1], imds=imds) self.assertAlmostEqual(e1_obt[0][0], -0.9074337292436309, 6) self.assertAlmostEqual(e1_obt[0][1], -0.9074337292161299, 6) self.assertAlmostEqual(e1_obt[0][2], -0.9074331788469051, 6) eom = EOMEA(mycc) imds = eom.make_imds(eris=eris) # Basic eaccsd e2_obt, v = eom.eaccsd(nroots=3, kptlist=[0], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.2669788613362731, 6) self.assertAlmostEqual(e2_obt[0][1], 1.2669788614703625, 6) self.assertAlmostEqual(e2_obt[0][2], 1.278883205515518, 6) # Ensure left is working e2_obt, v = eom.eaccsd(nroots=3, left=True, kptlist=[0], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.266978976813125, 6) self.assertAlmostEqual(e2_obt[0][1], 1.266978976822988, 6) self.assertAlmostEqual(e2_obt[0][2], 1.278883205348326, 6) # Ensure kptlist behaves correctly e2_obt, v = eom.eaccsd(nroots=3, koopmans=True, kptlist=[1], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.227583017804503, 6) self.assertAlmostEqual(e2_obt[0][1], 1.2275830178298166, 6) self.assertAlmostEqual(e2_obt[0][2], 1.3830379190440196, 6) # Basis eeccsd eom = EOMEE(mycc) imds = eom.make_imds(eris=eris) ee, v = eom.eeccsd(nroots=3, kptlist=[0], imds=imds) self.assertAlmostEqual(ee[0][0], 0.118301677904104, 6) self.assertAlmostEqual(ee[0][1], 0.118301914631351, 6) self.assertAlmostEqual(ee[0][2], 0.128285117266903, 6) ee, v = eom.eeccsd(nroots=3, kptlist=[1], imds=imds) self.assertAlmostEqual(ee[0][0], 0.07928010716890202, 6) self.assertAlmostEqual(ee[0][1], 0.07928011416043479, 6) self.assertAlmostEqual(ee[0][2], 0.07928011417159982, 6)
def test_n3_diffuse_Ta(self): '''Tests EOM-CCSD(T)*a method.''' cell = make_test_cell.test_cell_n3_diffuse() nmp = [1, 1, 2] ''' # treating 1*1*2 supercell at gamma point supcell = super_cell(cell,nmp) gmf = scf.GHF(supcell,exxdiv=None) gmf.conv_tol = 1e-10 gmf.conv_tol_grad = gmf.conv_tol * 10**2 ehf = gmf.kernel() gcc = cc.GCCSD(gmf) gcc.conv_tol=1e-12 gcc.conv_tol_normt=1e-10 gcc.max_cycle=250 ecc, t1, t2 = gcc.kernel() print('GHF energy (supercell) %.7f \n' % (float(ehf)/2.)) print('GCCSD correlation energy (supercell) %.7f \n' % (float(ecc)/2.)) eom = eom_gccsd.EOMIP_Ta(gcc) e1 = eom.ipccsd_star(nroots=6, koopmans=True) eom = eom_gccsd.EOMEA_Ta(gcc) e2 = eom.eaccsd_star(nroots=6, koopmans=True) ''' # Running HF and CCSD with 1x1x2 Monkhorst-Pack k-point mesh ehf2 = kmf.e_tot self.assertAlmostEqual(ehf2, -6.1870676561725695, 6) ecc2 = mycc.e_corr self.assertAlmostEqual(ecc2, -0.0676483716898783, 6) eom = EOMIP_Ta(mycc) imds = eom.make_imds(eris=eris) e1_obt, v = eom.ipccsd(nroots=3, koopmans=True, kptlist=[0], imds=imds) self.assertAlmostEqual(e1_obt[0][0], -1.146351234409813, 6) self.assertAlmostEqual(e1_obt[0][1], -1.146351234404151, 6) self.assertAlmostEqual(e1_obt[0][2], -1.107255699646373, 6) e1_obt = eom.ipccsd_star(nroots=3, koopmans=True, kptlist=[0], imds=imds) self.assertAlmostEqual(e1_obt[0][0], -1.143510075691, 6) self.assertAlmostEqual(e1_obt[0][1], -1.143510075684, 6) self.assertAlmostEqual(e1_obt[0][2], -1.116991306080, 6) eom = EOMEA_Ta(mycc) imds = eom.make_imds(eris=eris) e2_obt, v = eom.eaccsd(nroots=3, koopmans=True, kptlist=[0], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.267728934041309, 6) self.assertAlmostEqual(e2_obt[0][1], 1.267728934041309, 6) self.assertAlmostEqual(e2_obt[0][2], 1.280954980102639, 6) e2_obt, v = eom.eaccsd(nroots=3, koopmans=True, kptlist=[1], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.2290479727093149, 6) self.assertAlmostEqual(e2_obt[0][1], 1.2290479727093468, 6) self.assertAlmostEqual(e2_obt[0][2], 1.384154366703175, 6) e2_obt = eom.eaccsd_star(nroots=3, koopmans=True, kptlist=[1], imds=imds) self.assertAlmostEqual(e2_obt[0][0], 1.2229050426609025, 6) self.assertAlmostEqual(e2_obt[0][1], 1.2229050426609025, 6) self.assertAlmostEqual(e2_obt[0][2], 1.374851059956632, 6)
import pyscf.pbc.tools.make_test_cell as make_test_cell from pyscf.pbc.tools.pbc import super_cell from pyscf.pbc import gto, scf, cc from pyscf.pbc.cc.eom_kccsd_ghf import EOMIP, EOMEA, EOMEE from pyscf.pbc.cc.eom_kccsd_ghf import EOMIP_Ta, EOMEA_Ta from pyscf.cc import eom_gccsd import unittest cell = make_test_cell.test_cell_n3_diffuse() kmf = scf.KRHF(cell, kpts=cell.make_kpts([1, 1, 2], with_gamma_point=True), exxdiv=None) kmf.conv_tol = 1e-10 kmf.conv_tol_grad = 1e-6 kmf.scf() mycc = cc.KGCCSD(kmf) mycc.conv_tol = 1e-7 mycc.conv_tol_normt = 1e-7 mycc.run() eris = mycc.ao2mo() eris.mo_energy = [eris.fock[ikpt].diagonal() for ikpt in range(mycc.nkpts)] def tearDownModule(): global cell, kmf, mycc, eris cell.stdout.close() del cell, kmf, mycc, eris class KnownValues(unittest.TestCase):