Example #1
0
    def test_init_guess_atom(self):
        dm = scf.hf.init_guess_by_atom(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR)
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.041411845876416, 8)

        mf = scf.hf.RHF(mol)
        dm0 = scf.rhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.DHF(mol)
        dm0 = scf.dhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        pmol = gto.M(atom=mol.atom, basis='ccpvdz')
        pmol.cart = True
        dm = scf.hf.init_guess_by_atom(pmol)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 2.9173248538892547, 8)

        pmol = gto.M(atom='ghost-O 0 0 0; H 0 0 0.5; H 0 0.5 0',
                     basis='ccpvdz')
        dm = scf.hf.init_guess_by_atom(pmol)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 0.8436562326772896, 8)
Example #2
0
    def test_init_guess_1e(self):
        dm = scf.hf.init_guess_by_1e(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR)
        scf.chkfile.dump_scf(
            mol, ftmp.name, 0, occ, mo, occ,
            overwrite_mol=False)  # dump_scf twice to test overwrite_mol
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 5.3700828975288122, 9)

        mf = scf.hf.RHF(mol)
        dm0 = scf.rhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_1e(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.rohf.ROHF(mol)
        dm1 = mf.init_guess_by_1e(mol)
        self.assertAlmostEqual(numpy.linalg.norm(dm1),
                               5.3700828975288122 / numpy.sqrt(2), 9)

        mf = scf.rohf.ROHF(molsym)
        dm1 = mf.init_guess_by_1e(mol)
        self.assertAlmostEqual(numpy.linalg.norm(dm1),
                               5.3700828975288122 / numpy.sqrt(2), 9)

        mf = scf.DHF(mol)
        dm1 = mf.init_guess_by_1e(mol)
        self.assertAlmostEqual(numpy.linalg.norm(dm1), 7.5925205205065422, 9)
Example #3
0
    def test_rdirect_bindm(self):
        n2c = nao * 2
        eri0 = numpy.zeros((n2c, n2c, n2c, n2c), dtype=numpy.complex)
        mfr = scf.DHF(mol)
        mfr.scf()
        dm = mfr.make_rdm1()[:n2c, :n2c].copy()
        c_atm = numpy.array(mol._atm, dtype=numpy.int32)
        c_bas = numpy.array(mol._bas, dtype=numpy.int32)
        c_env = numpy.array(mol._env)
        i0 = 0
        for i in range(mol.nbas):
            j0 = 0
            for j in range(mol.nbas):
                k0 = 0
                for k in range(mol.nbas):
                    l0 = 0
                    for l in range(mol.nbas):
                        buf = gto.getints_by_shell('int2e_spsp1_spinor',
                                                   (i, j, k, l), c_atm, c_bas,
                                                   c_env, 1)
                        di, dj, dk, dl = buf.shape
                        eri0[i0:i0 + di, j0:j0 + dj, k0:k0 + dk,
                             l0:l0 + dl] = buf
                        l0 += dl
                    k0 += dk
                j0 += dj
            i0 += di

        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', ('jk->s1il', ),
                                 (dm, ), 1, mol._atm, mol._bas, mol._env)
        self.assertTrue(numpy.allclose(vk0, vk1))
Example #4
0
    def test_init_guess_atom(self):
        dm = scf.hf.init_guess_by_atom(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR)
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.064429619915702, 8)

        mf = scf.hf.RHF(mol)
        dm0 = scf.rhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.DHF(mol)
        dm0 = scf.dhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        pmol = gto.M(atom=mol.atom, basis='ccpvdz')
        pmol.cart = True
        dm = scf.hf.init_guess_by_atom(pmol)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 2.923422868807739, 8)

        pmol = gto.M(atom='ghost-O 0 0 0; H 0 0 0.5; H 0 0.5 0',
                     basis='ccpvdz')
        dm = scf.hf.init_guess_by_atom(pmol)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 0.86450726178750226, 8)
Example #5
0
 def test_dhf_nr_limit(self):
     mol = gto.M(atom='''
          H    .8    0.    0.
          H    0.    .5    0.''',
                 basis='ccpvdz')
     with lib.temporary_env(lib.param, LIGHT_SPEED=5000):
         r = scf.DHF(mol).run().EFG()
         nr = scf.RHF(mol).run().EFG()
     self.assertAlmostEqual(abs(r - nr).max(), 0, 7)
Example #6
0
    def test_init_guess_atom(self):
        dm = scf.hf.init_guess_by_atom(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR)
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.064429619915702, 8)

        mf = scf.hf.RHF(mol)
        dm0 = scf.rhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.DHF(mol)
        dm0 = scf.dhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.init_guess_by_atom(mol)
        self.assertTrue(numpy.allclose(dm0, dm1))
Example #7
0
    def test_init_guess_minao(self):
        dm = scf.hf.init_guess_by_minao(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile()
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.0334714065913508, 9)

        mf = scf.hf.RHF(mol)
        dm0 = scf.hf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.get_init_guess(key='minao')
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.DHF(mol)
        dm0 = scf.dhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.get_init_guess(key='minao')
        self.assertTrue(numpy.allclose(dm0, dm1))
Example #8
0
    def test_dhf_grad_with_ssss_high_cost(self):
        with lib.light_speed(30):
            mf = scf.DHF(h2o).run()
            g = mf.nuc_grad_method().kernel()
            self.assertAlmostEqual(lib.finger(g), 0.0074940105486053926, 7)

            ms = mf.as_scanner()
            pmol = h2o.copy()
            e1 = ms(
                pmol.set_geom_([["O",
                                 (0., 0., -0.001)], [1, (0., -0.757, 0.587)],
                                [1, (0., 0.757, 0.587)]],
                               unit='Ang'))
            e2 = ms(
                pmol.set_geom_([["O",
                                 (0., 0., 0.001)], [1, (0., -0.757, 0.587)],
                                [1, (0., 0.757, 0.587)]],
                               unit='Ang'))
            self.assertAlmostEqual(g[0, 2], (e2 - e1) / 0.002 * lib.param.BOHR,
                                   6)
Example #9
0
    def test_init_guess_minao(self):
        dm = scf.hf.init_guess_by_minao(mol)
        s = scf.hf.get_ovlp(mol)
        occ, mo = scipy.linalg.eigh(dm, s, type=2)
        ftmp = tempfile.NamedTemporaryFile(dir=lib.param.TMPDIR)
        scf.chkfile.dump_scf(mol, ftmp.name, 0, occ, mo, occ)
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.0334714065913508, 9)

        mf = scf.hf.RHF(mol)
        dm0 = scf.hf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.get_init_guess(key='minao')
        self.assertTrue(numpy.allclose(dm0, dm1))

        mf = scf.DHF(mol)
        dm0 = scf.dhf.init_guess_by_chkfile(mol, ftmp.name, project=False)
        dm1 = mf.get_init_guess(key='minao')
        self.assertTrue(numpy.allclose(dm0, dm1))

        pmol = gto.M(atom='ghost-O 0 0 0; H 0 0 0.5; H 0 0.5 0', basis='ccpvdz')
        dm1 = mf.get_init_guess(key='minao')
        self.assertAlmostEqual(numpy.linalg.norm(dm), 3.0334714065913482, 8)
Example #10
0
    def fjk(mol, dm, *args, **kwargs):
        # dm is 4C density matrix
        cderi_ll = cderi[0].reshape(-1, n2c, n2c)
        cderi_ss = cderi[1].reshape(-1, n2c, n2c)
        vj = numpy.zeros((n2c * 2, n2c * 2), dtype=dm.dtype)
        vk = numpy.zeros((n2c * 2, n2c * 2), dtype=dm.dtype)

        rho = (numpy.dot(cderi[0], dm[:n2c, :n2c].T.reshape(-1)) +
               numpy.dot(cderi[1], dm[n2c:, n2c:].T.reshape(-1) * c2**2))
        vj[:n2c, :n2c] = numpy.dot(rho, cderi[0]).reshape(n2c, n2c)
        vj[n2c:, n2c:] = numpy.dot(rho, cderi[1]).reshape(n2c, n2c) * c2**2

        v1 = numpy.einsum('pij,jk->pik', cderi_ll, dm[:n2c, :n2c])
        vk[:n2c, :n2c] = numpy.einsum('pik,pkj->ij', v1, cderi_ll)
        v1 = numpy.einsum('pij,jk->pik', cderi_ss, dm[n2c:, n2c:])
        vk[n2c:, n2c:] = numpy.einsum('pik,pkj->ij', v1, cderi_ss) * c2**4
        v1 = numpy.einsum('pij,jk->pik', cderi_ll, dm[:n2c, n2c:])
        vk[:n2c, n2c:] = numpy.einsum('pik,pkj->ij', v1, cderi_ss) * c2**2
        vk[n2c:, :n2c] = vk[:n2c, n2c:].T.conj()
        return vj, vk

    mf = scf.DHF(mol)
    mf.get_jk = fjk
    mf.direct_scf = False
    ehf1 = mf.scf()
    print(ehf1, -76.08073868516945)

    cderi = cderi[0].reshape(-1, n2c, n2c)
    print(numpy.allclose(cderi, cderi.transpose(0, 2, 1).conj()))
Example #11
0
        return vind

SSC = SpinSpinCoupling

if __name__ == '__main__':
    from pyscf import gto
    from pyscf import scf
    mol = gto.Mole()
    mol.verbose = 3
    mol.output = None

    mol.atom.extend([
        [1, (0., 0., .917)],
        ['F', (0., 0., 0.)],
    ])
    mol.nucmod = {'F': 2}  # gaussian nuclear model
    mol.basis = {
        'H': '6-31g',
        'F': '6-31g',
    }
    mol.build()

    rhf = scf.DHF(mol).run()
    ssc = SSC(rhf)
    ssc.cphf = True
    #ssc.mb = 'RKB' # 'RMB'
    jj = ssc.kernel()
    print(jj)
    print(lib.finger(jj) * 1e8 - 0.12144116396441988)
Example #12
0
    def test_init(self):
        from pyscf import dft
        from pyscf import x2c
        mol_r = mol
        mol_u = gto.M(atom='Li', spin=1, verbose=0)
        mol_r1 = gto.M(atom='H', spin=1, verbose=0)
        sym_mol_r = molsym
        sym_mol_u = gto.M(atom='Li', spin=1, symmetry=1, verbose=0)
        sym_mol_r1 = gto.M(atom='H', spin=1, symmetry=1, verbose=0)
        self.assertTrue(isinstance(scf.RKS(mol_r), dft.rks.RKS))
        self.assertTrue(isinstance(scf.RKS(mol_u), dft.roks.ROKS))
        self.assertTrue(isinstance(scf.UKS(mol_r), dft.uks.UKS))
        self.assertTrue(isinstance(scf.ROKS(mol_r), dft.roks.ROKS))
        self.assertTrue(isinstance(scf.GKS(mol_r), dft.gks.GKS))
        self.assertTrue(isinstance(scf.KS(mol_r), dft.rks.RKS))
        self.assertTrue(isinstance(scf.KS(mol_u), dft.uks.UKS))

        self.assertTrue(isinstance(scf.RHF(mol_r), scf.hf.RHF))
        self.assertTrue(isinstance(scf.RHF(mol_u), scf.rohf.ROHF))
        self.assertTrue(isinstance(scf.RHF(mol_r1), scf.rohf.ROHF))
        self.assertTrue(isinstance(scf.UHF(mol_r), scf.uhf.UHF))
        self.assertTrue(isinstance(scf.UHF(mol_u), scf.uhf.UHF))
        self.assertTrue(isinstance(scf.UHF(mol_r1), scf.uhf.HF1e))
        self.assertTrue(isinstance(scf.ROHF(mol_r), scf.rohf.ROHF))
        self.assertTrue(isinstance(scf.ROHF(mol_u), scf.rohf.ROHF))
        self.assertTrue(isinstance(scf.ROHF(mol_r1), scf.rohf.HF1e))
        self.assertTrue(isinstance(scf.HF(mol_r), scf.hf.RHF))
        self.assertTrue(isinstance(scf.HF(mol_u), scf.uhf.UHF))
        self.assertTrue(isinstance(scf.HF(mol_r1), scf.rohf.HF1e))
        self.assertTrue(isinstance(scf.GHF(mol_r), scf.ghf.GHF))
        self.assertTrue(isinstance(scf.GHF(mol_u), scf.ghf.GHF))
        self.assertTrue(isinstance(scf.GHF(mol_r1), scf.ghf.HF1e))
        #TODO: self.assertTrue(isinstance(scf.DHF(mol_r), scf.dhf.RHF))
        self.assertTrue(isinstance(scf.DHF(mol_u), scf.dhf.UHF))
        self.assertTrue(isinstance(scf.DHF(mol_r1), scf.dhf.HF1e))

        self.assertTrue(isinstance(scf.RHF(sym_mol_r), scf.hf_symm.RHF))
        self.assertTrue(isinstance(scf.RHF(sym_mol_u), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.RHF(sym_mol_r1), scf.hf_symm.HF1e))
        self.assertTrue(isinstance(scf.UHF(sym_mol_r), scf.uhf_symm.UHF))
        self.assertTrue(isinstance(scf.UHF(sym_mol_u), scf.uhf_symm.UHF))
        self.assertTrue(isinstance(scf.UHF(sym_mol_r1), scf.uhf_symm.HF1e))
        self.assertTrue(isinstance(scf.ROHF(sym_mol_r), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.ROHF(sym_mol_u), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.ROHF(sym_mol_r1), scf.hf_symm.HF1e))
        self.assertTrue(isinstance(scf.HF(sym_mol_r), scf.hf_symm.RHF))
        self.assertTrue(isinstance(scf.HF(sym_mol_u), scf.uhf_symm.UHF))
        self.assertTrue(isinstance(scf.HF(sym_mol_r1), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.GHF(sym_mol_r), scf.ghf_symm.GHF))
        self.assertTrue(isinstance(scf.GHF(sym_mol_u), scf.ghf_symm.GHF))
        self.assertTrue(isinstance(scf.GHF(sym_mol_r1), scf.ghf_symm.HF1e))

        self.assertTrue(isinstance(scf.X2C(mol_r), x2c.x2c.UHF))
        self.assertTrue(isinstance(scf.sfx2c1e(scf.HF(mol_r)), scf.rhf.RHF))
        self.assertTrue(isinstance(scf.sfx2c1e(scf.HF(mol_u)), scf.uhf.UHF))
        self.assertTrue(isinstance(scf.sfx2c1e(scf.HF(mol_r1)), scf.rohf.ROHF))
        self.assertTrue(
            isinstance(scf.sfx2c1e(scf.HF(sym_mol_r)), scf.rhf_symm.RHF))
        self.assertTrue(
            isinstance(scf.sfx2c1e(scf.HF(sym_mol_u)), scf.uhf_symm.UHF))
        self.assertTrue(
            isinstance(scf.sfx2c1e(scf.HF(sym_mol_r1)), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.density_fit(scf.HF(mol_r)),
                                   scf.rhf.RHF))
        self.assertTrue(isinstance(scf.density_fit(scf.HF(mol_u)),
                                   scf.uhf.UHF))
        self.assertTrue(
            isinstance(scf.density_fit(scf.HF(mol_r1)), scf.rohf.ROHF))
        self.assertTrue(
            isinstance(scf.density_fit(scf.HF(sym_mol_r)), scf.rhf_symm.RHF))
        self.assertTrue(
            isinstance(scf.density_fit(scf.HF(sym_mol_u)), scf.uhf_symm.UHF))
        self.assertTrue(
            isinstance(scf.density_fit(scf.HF(sym_mol_r1)), scf.hf_symm.ROHF))
        self.assertTrue(isinstance(scf.newton(scf.HF(mol_r)), scf.rhf.RHF))
        self.assertTrue(isinstance(scf.newton(scf.HF(mol_u)), scf.uhf.UHF))
        self.assertTrue(isinstance(scf.newton(scf.HF(mol_r1)), scf.rohf.ROHF))
        self.assertTrue(
            isinstance(scf.newton(scf.HF(sym_mol_r)), scf.rhf_symm.RHF))
        self.assertTrue(
            isinstance(scf.newton(scf.HF(sym_mol_u)), scf.uhf_symm.UHF))
        self.assertTrue(
            isinstance(scf.newton(scf.HF(sym_mol_r1)), scf.hf_symm.ROHF))
Example #13
0
 def test_r_rhf(self):
     uhf = scf.DHF(mol)
     uhf.conv_tol_grad = 1e-5
     self.assertAlmostEqual(uhf.scf(), -76.038520463270061, 7)
Example #14
0
 def test_dhf(self):
     pmol = mol.copy()
     pmol.build(False, False)
     mf = scf.density_fit(scf.DHF(pmol), auxbasis='weigend')
     mf.conv_tol = 1e-10
     self.assertAlmostEqual(mf.scf(), -76.080738677021458, 8)
Example #15
0
 def test_dhf(self):
     pmol = mol.copy()
     pmol.build(False, False)
     mf = scf.density_fit(scf.DHF(pmol))
     mf.conv_tol_grad = 1e-5
     self.assertAlmostEqual(mf.scf(), -76.080738677021458, 8)
Example #16
0
    def test_convert(self):
        rhf = scf.RHF(mol)
        uhf = scf.UHF(mol)
        ghf = scf.GHF(mol)
        rks = dft.RKS(mol)
        uks = dft.UKS(mol)
        gks = dft.GKS(mol)
        dhf = scf.DHF(mol)
        dks = dft.DKS(mol)
        udhf = scf.dhf.UDHF(mol)
        udks = dft.dks.UDKS(mol)

        self.assertTrue(isinstance(rhf.to_rhf(), scf.rhf.RHF))
        self.assertTrue(isinstance(rhf.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(rhf.to_ghf(), scf.ghf.GHF))
        self.assertTrue(isinstance(rhf.to_rks(), dft.rks.RKS))
        self.assertTrue(isinstance(rhf.to_uks(), dft.uks.UKS))
        self.assertTrue(isinstance(rhf.to_gks(), dft.gks.GKS))

        self.assertTrue(isinstance(rks.to_rhf(), scf.rhf.RHF))
        self.assertTrue(isinstance(rks.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(rks.to_ghf(), scf.ghf.GHF))
        self.assertTrue(isinstance(rks.to_rks('pbe'), dft.rks.RKS))
        self.assertTrue(isinstance(rks.to_uks('pbe'), dft.uks.UKS))
        self.assertTrue(isinstance(rks.to_gks('pbe'), dft.gks.GKS))

        self.assertTrue(isinstance(uhf.to_rhf(), scf.rhf.RHF))
        self.assertTrue(isinstance(uhf.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(uhf.to_ghf(), scf.ghf.GHF))
        self.assertTrue(isinstance(uhf.to_rks(), dft.rks.RKS))
        self.assertTrue(isinstance(uhf.to_uks(), dft.uks.UKS))
        self.assertTrue(isinstance(uhf.to_gks(), dft.gks.GKS))

        self.assertTrue(isinstance(rks.to_rhf(), scf.rhf.RHF))
        self.assertTrue(isinstance(rks.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(rks.to_ghf(), scf.ghf.GHF))
        self.assertTrue(isinstance(uks.to_rks('pbe'), dft.rks.RKS))
        self.assertTrue(isinstance(uks.to_uks('pbe'), dft.uks.UKS))
        self.assertTrue(isinstance(uks.to_gks('pbe'), dft.gks.GKS))

        #self.assertTrue(isinstance(ghf.to_rhf(), scf.rhf.RHF))
        #self.assertTrue(isinstance(ghf.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(ghf.to_ghf(), scf.ghf.GHF))
        #self.assertTrue(isinstance(ghf.to_rks(), dft.rks.RKS))
        #self.assertTrue(isinstance(ghf.to_uks(), dft.uks.UKS))
        self.assertTrue(isinstance(ghf.to_gks(), dft.gks.GKS))

        #self.assertTrue(isinstance(gks.to_rhf(), scf.rhf.RHF))
        #self.assertTrue(isinstance(gks.to_uhf(), scf.uhf.UHF))
        self.assertTrue(isinstance(gks.to_ghf(), scf.ghf.GHF))
        #self.assertTrue(isinstance(gks.to_rks('pbe'), dft.rks.RKS))
        #self.assertTrue(isinstance(gks.to_uks('pbe'), dft.uks.UKS))
        self.assertTrue(isinstance(gks.to_gks('pbe'), dft.gks.GKS))

        self.assertRaises(RuntimeError, dhf.to_rhf)
        self.assertRaises(RuntimeError, dhf.to_uhf)
        self.assertRaises(RuntimeError, dhf.to_ghf)
        self.assertRaises(RuntimeError, dks.to_rks)
        self.assertRaises(RuntimeError, dks.to_uks)
        self.assertRaises(RuntimeError, dks.to_gks)

        if scf.dhf.zquatev is not None:
            self.assertTrue(isinstance(dhf.to_dhf(), scf.dhf.RDHF))
            self.assertTrue(isinstance(dhf.to_dks(), dft.dks.RDKS))
            self.assertTrue(isinstance(dks.to_dhf(), scf.dhf.RDHF))
            self.assertTrue(isinstance(dks.to_dks('pbe'), dft.dks.RDKS))
        self.assertTrue(isinstance(dhf.to_dhf(), scf.dhf.DHF))
        self.assertTrue(isinstance(dhf.to_dks(), dft.dks.DKS))
        self.assertTrue(isinstance(dks.to_dhf(), scf.dhf.DHF))
        self.assertTrue(isinstance(dks.to_dks('pbe'), dft.dks.DKS))
        self.assertTrue(isinstance(udhf.to_dhf(), scf.dhf.DHF))
        self.assertTrue(isinstance(udhf.to_dks(), dft.dks.DKS))
        self.assertTrue(isinstance(udks.to_dhf(), scf.dhf.DHF))
        self.assertTrue(isinstance(udks.to_dks('pbe'), dft.dks.DKS))