Example #1
0
def test_rks_energy_df(xc, atomzs, dist, energy_true, grid):
    # test to see if the energy calculated by DQC agrees with PySCF using
    # density fitting
    poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]],
                        dtype=dtype) * dist
    mol = Mol((atomzs, poss), basis="6-311++G**", dtype=dtype, grid=grid)
    mol.densityfit(method="coulomb", auxbasis="def2-sv(p)-jkfit")
    qc = KS(mol, xc=xc, restricted=True).run()
    ene = qc.energy()
    assert torch.allclose(ene, ene * 0 + energy_true)
Example #2
0
def test_uks_energy_mols_df(xc, atomzs, dist, spin, energy_true):
    # check the energy of molecules with non-0 spins with density fitting
    poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]],
                        dtype=dtype) * dist
    mol = Mol((atomzs, poss),
              basis="6-311++G**",
              grid=3,
              dtype=dtype,
              spin=spin)
    mol.densityfit(method="coulomb", auxbasis="def2-sv(p)-jkfit")
    qc = KS(mol, xc=xc, restricted=False).run()
    ene = qc.energy()
    assert torch.allclose(ene, ene * 0 + energy_true, rtol=1e-6, atol=0.0)
Example #3
0
def test_rks_energy_df(xc, atomzs, dist, energy_true, grid):
    # test to see if the energy calculated by DQC agrees with PySCF using
    # density fitting
    if xc == "mgga_x_scan":
        if atomzs == [1, 1]:
            pytest.xfail("Psi4 and PySCF don't converge")

    for lowmem in [False, True]:  # simulating low memory condition
        if lowmem:
            init_value = config.THRESHOLD_MEMORY
            config.THRESHOLD_MEMORY = 1000000  # 1 MB

        poss = torch.tensor([[-0.5, 0.0, 0.0], [0.5, 0.0, 0.0]],
                            dtype=dtype) * dist
        mol = Mol((atomzs, poss), basis="6-311++G**", dtype=dtype, grid=grid)
        mol.densityfit(method="coulomb", auxbasis="def2-sv(p)-jkfit")
        qc = KS(mol, xc=xc, restricted=True).run()
        ene = qc.energy()
        # error to be < 1 kcal/mol
        assert torch.allclose(ene, ene * 0 + energy_true, atol=1.1e-3, rtol=0)

        if lowmem:
            # restore the value
            config.THRESHOLD_MEMORY = init_value