Esempio n. 1
0
def test_cc_t2f():  # pragma: nocover
    from pyscf import gto
    from pyscf import scf
    mol = gto.Mole()
    mol.atom = [
        [8, (0., 0., 0.)],
        [1, (0.,  -0.757, 0.587)],
        [1, (0., 0.757, 0.587)]]
    mol.basis = {'H': '3-21g',
                 'O': '3-21g', }
    mol.build()
    rhf = scf.RHF(mol)
    rhf.scf()
    rhfri = scf.density_fit(scf.RHF(mol))
    rhfri.scf()

    from tcc.rccsdt import RCCSDT, RCCSDT_UNIT
    from tcc.rccsdt_cpd import (RCCSDT_UNIT_nCPD_LS_T,
                                RCCSDT_UNIT_nCPD_T_LS_T)
    from tcc.cc_solvers import (classic_solver, step_solver)

    cc1 = RCCSDT_UNIT(rhf)
    cc2 = RCCSDT_UNIT_nCPD_T_LS_T(rhfri, rankt={'t3': 40})

    converged1, energy1, amps1 = classic_solver(
        cc1, conv_tol_energy=1e-7, lam=3,
        max_cycle=100)

    converged2, energy2, amps2 = step_solver(
        cc2, conv_tol_energy=1e-7, beta=1 - 1 / 5,
        max_cycle=100)

    print('E(full) - E(T2 CPD): {}'.format(energy2 - energy1))
Esempio n. 2
0
def test_cc_step():  # pragma: nocover
    from pyscf import gto
    from pyscf import scf
    mol = gto.Mole()
    mol.atom = [[8, (0., 0., 0.)], [1, (0., -0.757, 0.587)],
                [1, (0., 0.757, 0.587)]]

    mol.basis = {
        'H': 'sto-3g',
        'O': 'sto-3g',
    }
    mol.build()
    rhf = scf.RHF(mol)
    rhf.scf()  # -76.0267656731

    from tcc.cc_solvers import step_solver, classic_solver
    from tcc.rccsd import RCCSD
    cc = RCCSD(rhf)

    converged1, energy1, _ = classic_solver(cc,
                                            conv_tol_energy=1e-10,
                                            conv_tol_res=1e-10,
                                            max_cycle=20)
    cc._converged = False

    converged2, energy2, _ = step_solver(cc,
                                         conv_tol_energy=1e-10,
                                         beta=0.5,
                                         max_cycle=100)
Esempio n. 3
0
def test_cpd_unf():
    from pyscf import gto
    from pyscf import scf
    mol = gto.Mole()
    mol.atom = [[8, (0., 0., 0.)], [1, (0., -0.757, 0.587)],
                [1, (0., 0.757, 0.587)]]

    mol.basis = {
        'H': '3-21g',
        'O': '3-21g',
    }
    mol.build()
    rhf_ri = scf.density_fit(scf.RHF(mol))
    rhf_ri.scf()  # -76.0267656731

    from tcc.rccsd import RCCSD, RCCSD_DIR_RI
    from tcc.rccsd_cpd import (RCCSD_nCPD_LS_T, RCCSD_CPD_LS_T)

    from tcc.cc_solvers import (classic_solver, step_solver)

    cc1 = RCCSD_DIR_RI(rhf_ri)
    cc2 = RCCSD_nCPD_LS_T(rhf_ri, rankt={'t2': 30})
    cc3 = RCCSD_CPD_LS_T(rhf_ri, rankt={'t2': 30})

    converged1, energy1, amps1 = classic_solver(
        cc1,
        conv_tol_energy=1e-8,
    )

    converged2, energy2, amps2 = classic_solver(cc2,
                                                conv_tol_energy=1e-8,
                                                max_cycle=50)

    converged2, energy2, amps2 = step_solver(cc2,
                                             conv_tol_energy=1e-8,
                                             beta=0,
                                             max_cycle=150)

    converged3, energy3, amps3 = classic_solver(cc3,
                                                conv_tol_energy=1e-8,
                                                max_cycle=50)

    converged3, energy3, amps3 = step_solver(cc3,
                                             conv_tol_energy=1e-8,
                                             beta=0,
                                             max_cycle=150)
Esempio n. 4
0
def test_cc():  # pragma: nocover
    from pyscf import gto
    from pyscf import scf
    mol = gto.Mole()
    mol.atom = [[8, (0., 0., 0.)], [1, (0., -0.757, 0.587)],
                [1, (0., 0.757, 0.587)]]
    mol.basis = {
        'H': '3-21g',
        'O': '3-21g',
    }
    mol.build()
    rhf = scf.RHF(mol)
    rhf = scf.density_fit(scf.RHF(mol))
    rhf.scf()

    from tcc.rccsdt_ri import RCCSDT_RI
    from tcc.rccsdt_cpd import RCCSDT_nCPD_LS_T
    from tcc.rccsdt_cpd import RCCSDT_CPD_LS_T
    from tcc.cc_solvers import (classic_solver, step_solver)
    cc1 = RCCSDT_RI(rhf)
    cc2 = RCCSDT_nCPD_LS_T(rhf, rankt={'t2': 20, 't3': 40})
    cc3 = RCCSDT_CPD_LS_T(rhf, rankt={'t2': 20, 't3': 40})

    converged1, energy1, amps1 = classic_solver(cc1,
                                                conv_tol_energy=1e-9,
                                                conv_tol_res=1e-8,
                                                max_cycle=100)

    print('dE: {}'.format(energy1 - -1.304876e-01))

    import numpy as np
    np.seterr(all='raise')
    import warnings
    warnings.filterwarnings("error")

    converged2, energy2, amps2 = step_solver(cc2,
                                             conv_tol_energy=1e-8,
                                             max_cycle=100)

    converged3, energy3, amps3 = step_solver(cc3,
                                             conv_tol_energy=1e-8,
                                             max_cycle=100)

    print('dE: {}'.format(energy2 - -0.12621546190311517))
    print('E(CPD)-E(nCPD): {}'.format(energy3 - energy2))