def test_t1_d1_openshell(self): """Test open shell t1-diagnostic by reducing back to closed shell""" mol = gto.M() mol.atom = 'N 0 0 0; N 0 0 1.4' mol.basis = 'cc-pvtz' mol.spin = 0 mol.build() mf = scf.RHF(mol) mf.kernel() mycc = cc.CCSD(mf) mycc.kernel() true_t1d, true_d1d = mycc.get_t1_diagnostic(), mycc.get_d1_diagnostic() uhf_mf = scf.convert_to_uhf(mf) mycc_uhf = cc.CCSD(uhf_mf) mycc_uhf.kernel() t1a, t1b = mycc_uhf.t1 test_t1d, test_d1d = open_shell_t1_d1( t1a, t1b, uhf_mf.mo_occ[0] + uhf_mf.mo_occ[1], uhf_mf.nelec[0], uhf_mf.nelec[1]) assert np.isclose(test_t1d, true_t1d) assert np.isclose(test_d1d, true_d1d) assert np.sqrt(2) * test_t1d <= test_d1d
def test_init(self): self.assertTrue(isinstance(cc.CCSD(mf), ccsd.CCSD)) self.assertTrue(isinstance(cc.CCSD(mf.density_fit()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.CCSD(mf.newton()), ccsd.CCSD)) self.assertTrue(isinstance(cc.CCSD(mf.density_fit().newton()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.CCSD(mf.newton().density_fit()), ccsd.CCSD)) self.assertTrue(not isinstance(cc.CCSD(mf.newton().density_fit()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.CCSD(mf.density_fit().newton().density_fit()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.UCCSD(mf), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.UCCSD(mf.newton()), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit().newton()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.UCCSD(mf.newton().density_fit()), uccsd.UCCSD)) # self.assertTrue(not isinstance(cc.UCCSD(mf.newton().density_fit()), dfccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit().newton().density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.CCSD(scf.GHF(mol)), gccsd.GCCSD)) umf = scf.convert_to_uhf(mf, scf.UHF(mol)) self.assertTrue(isinstance(cc.CCSD(umf), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.CCSD(umf.density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.CCSD(umf.newton()), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.CCSD(umf.density_fit().newton()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.CCSD(umf.newton().density_fit()), uccsd.UCCSD)) # self.assertTrue(not isinstance(cc.CCSD(umf.newton().density_fit()), dfccsd.UCCSD)) # self.assertTrue(isinstance(cc.CCSD(umf.density_fit().newton().density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.CCSD(mf, mo_coeff=mf.mo_coeff*1j), rccsd.RCCSD))
def test_init(self): from pyscf.cc import ccsd from pyscf.cc import uccsd from pyscf.cc import dfccsd self.assertTrue(isinstance(cc.CCSD(mf), ccsd.CCSD)) self.assertTrue(isinstance(cc.CCSD(mf.density_fit()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.CCSD(mf.newton()), ccsd.CCSD)) self.assertTrue( isinstance(cc.CCSD(mf.density_fit().newton()), dfccsd.RCCSD)) self.assertTrue( isinstance(cc.CCSD(mf.newton().density_fit()), ccsd.CCSD)) self.assertTrue( not isinstance(cc.CCSD(mf.newton().density_fit()), dfccsd.RCCSD)) self.assertTrue( isinstance(cc.CCSD(mf.density_fit().newton().density_fit()), dfccsd.RCCSD)) self.assertTrue(isinstance(cc.UCCSD(mf), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.UCCSD(mf.newton()), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit().newton()), dfccsd.UCCSD)) self.assertTrue( isinstance(cc.UCCSD(mf.newton().density_fit()), uccsd.UCCSD)) # self.assertTrue(not isinstance(cc.UCCSD(mf.newton().density_fit()), dfccsd.UCCSD)) # self.assertTrue(isinstance(cc.UCCSD(mf.density_fit().newton().density_fit()), dfccsd.UCCSD)) umf = scf.convert_to_uhf(mf, scf.UHF(mol)) self.assertTrue(isinstance(cc.CCSD(umf), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.CCSD(umf.density_fit()), dfccsd.UCCSD)) self.assertTrue(isinstance(cc.CCSD(umf.newton()), uccsd.UCCSD)) # self.assertTrue(isinstance(cc.CCSD(umf.density_fit().newton()), dfccsd.UCCSD)) self.assertTrue( isinstance(cc.CCSD(umf.newton().density_fit()), uccsd.UCCSD))
def test_t1_d1_oxygen(self): """Test open shell t1-diagnostic on O2 molecule Compare with output from Psi4 * Input: molecule oxygen { 0 3 O 0.0 0.0 0.0 O 0.0 0.0 1.1 no_reorient symmetry c1 } set { reference rohf basis cc-pvtz } energy('CCSD') * Output @ROHF Final Energy: -149.65170765644311 Solving CC Amplitude Equations ------------------------------ Iter Energy RMS T1Diag D1Diag New D1Diag ---- ---------- --------- ---------- ---------- ---------- ... 10 -0.464506 1.907e-07 0.004390 0.009077 0.009077 11 -0.464506 5.104e-08 0.004390 0.009077 0.009077 Iterations converged. """ mol = gto.M() mol.atom = 'O 0 0 0; O 0 0 1.1' mol.basis = 'cc-pvtz' mol.spin = 2 mol.build() mf = scf.ROHF(mol) mf.kernel() uhf_mf = scf.convert_to_uhf(mf) mycc_uhf = cc.CCSD(mf) mycc_uhf.kernel() t1a, t1b = mycc_uhf.t1 test_t1d, test_d1d = open_shell_t1_d1( t1a, t1b, uhf_mf.mo_occ[0] + uhf_mf.mo_occ[1], uhf_mf.nelec[0], uhf_mf.nelec[1]) assert np.isclose(mf.e_tot, -149.651708, atol=1e-6) assert np.isclose(mycc_uhf.e_corr, -0.464507, atol=1e-6) assert np.isclose(test_t1d, 0.004390, atol=1e-4) assert np.isclose(test_d1d, 0.009077, atol=1e-4)
def test_uhf_stability(self): mf1 = scf.convert_to_uhf(mf) mo_i, mo_e = mf1.stability(internal=True, external=True) s = mf1.det_ovlp(mo_i, mf1.mo_coeff, mf1.mo_occ, mf1.mo_occ, mf1.get_ovlp())[0] self.assertAlmostEqual(s, 1, 9) self.assertAlmostEqual(abs(mf1.mo_coeff[0] - mo_i[0]).max(), 0, 9) self.assertAlmostEqual(abs(mf1.mo_coeff[1] - mo_i[1]).max(), 0, 9) self.assertEqual(mo_e.shape, (56, 56)) mf1 = scf.convert_to_ghf(mf).newton() s = mf1.det_ovlp(mo_e, mf1.mo_coeff, mf1.mo_occ, mf1.mo_occ, mf1.get_ovlp())[0] self.assertAlmostEqual(s, 0.57993272190912937, 6) mf1.kernel(mo_coeff=mo_e, mo_occ=mf1.mo_occ) self.assertAlmostEqual(mf1.e_tot, -149.6097443357186, 8)
def test_uhf_stability(self): mf1 = scf.convert_to_uhf(mf) mo_i, mo_e = mf1.stability(internal=True, external=True) s = mf1.det_ovlp(mo_i, mf1.mo_coeff, mf1.mo_occ, mf1.mo_occ, mf1.get_ovlp())[0] self.assertAlmostEqual(s, 1, 9) self.assertAlmostEqual(abs(mf1.mo_coeff[0]-mo_i[0]).max(), 0, 9) self.assertAlmostEqual(abs(mf1.mo_coeff[1]-mo_i[1]).max(), 0, 9) self.assertEqual(mo_e.shape, (56,56)) mf1 = scf.convert_to_ghf(mf).newton() s = mf1.det_ovlp(mo_e, mf1.mo_coeff, mf1.mo_occ, mf1.mo_occ, mf1.get_ovlp())[0] self.assertAlmostEqual(s, 0.57993272190912937, 6) mf1.kernel(mo_coeff=mo_e, mo_occ=mf1.mo_occ) self.assertAlmostEqual(mf1.e_tot, -149.6097443357186, 8)
def test_t1_d1_bound(self): """sqrt(2) * t1 <= d1""" mol = gto.M() mol.atom = 'O 0 0 0; O 0 0 1.4' mol.basis = 'cc-pvtz' mol.spin = 2 mol.build() mf = scf.ROHF(mol) mf.kernel() mycc = cc.CCSD(mf) mycc.kernel() uhf_mf = scf.convert_to_uhf(mf) mycc_uhf = cc.CCSD(uhf_mf) mycc_uhf.kernel() t1a, t1b = mycc_uhf.t1 test_t1d, test_d1d = open_shell_t1_d1( t1a, t1b, uhf_mf.mo_occ[0] + uhf_mf.mo_occ[1], uhf_mf.nelec[0], uhf_mf.nelec[1]) assert np.sqrt(2) * test_t1d <= test_d1d
gobj.so_eff_charge = True gobj.kernel() # # Attribute gauge_orig controls whether to use GIAO. GIAO is used by default. # gobj.gauge_orig = mol.atom_coord(1) # on N atom gobj.dia_soc2e = False gobj.para_soc2e = True gobj.so_eff_charge = False gobj.kernel() # # In pure DFT (LDA, GGA), CPSCF has no effects. Setting cphf=False can switch # off CPSCF. # mf = dft.UKS(mol).set(xc='bp86').run() gobj = gtensor.uks.GTensor(mf).set(verbose=4) gobj.cphf = False gobj.gauge_orig = (0, 0, 0) gobj.kernel() # # Only UHF and UKS are supported in g-tensor module. ROHF and ROKS need to be # transfered to UHF or UKS before calling g-tensor methods. # mf = scf.RKS(mol).run() mf = scf.convert_to_uhf(mf) gobj = gtensor.uhf.GTensor(mf).set(verbose=4) print(gobj.kernel())