Exemplo n.º 1
0
def test_reference_energy():
    gos_system = construct_pyscf_system_rhf("li 0.0 0.0 0.0; h 0.0 0.0 3.08",
                                            basis="cc-pvdz")
    spas_system = construct_pyscf_system_rhf("li 0.0 0.0 0.0; h 0.0 0.0 3.08",
                                             basis="cc-pvdz",
                                             add_spin=False)

    # This energy is found from PySCF's RHF solver
    lih_energy = -7.98367215457454

    assert abs(gos_system.compute_reference_energy() - lih_energy) < 1e-8
    assert abs(spas_system.compute_reference_energy() - lih_energy) < 1e-8
Exemplo n.º 2
0
def test_reference_energy():
    system = construct_pyscf_system_rhf("he", basis="cc-pvdz")

    # This energy is found from PySCF's RHF solver
    he_energy = -2.85516047724274

    assert abs(system.compute_reference_energy() - he_energy) < 1e-8
Exemplo n.º 3
0
def test_spin_squared_constructions():
    # TODO: Try to make this test applicable for non-orthonomal basis sets.

    # n = 2
    # l = 10
    # system = GeneralOrbitalSystem(n, RandomBasisSet(l, 3))
    # system = GeneralOrbitalSystem(
    #     n, ODQD(l, 10, 1001, potential=ODQD.HOPotential(1))
    # )

    # system = construct_pyscf_system_ao("he")

    system = construct_pyscf_system_rhf("he", basis="cc-pVTZ")

    spin_dir_tb_orig = []
    spin_dir_tb_pm = []

    spin_p = system.spin_x + 1j * system.spin_y
    spin_m = system.spin_x - 1j * system.spin_y
    spin_z = system.spin_z
    s = system.s

    np.testing.assert_allclose(spin_p @ s @ spin_m - spin_m @ s @ spin_p,
                               2 * spin_z,
                               atol=1e-10)

    # S^2 = S_- * S_+ + S_z + S_z^2
    spin_2_mp = spin_m @ spin_p + spin_z + spin_z @ spin_z
    spin_2_tb_mp = (0.5 * np.einsum("pr, qs -> pqrs", spin_m, spin_p) +
                    0.5 * np.einsum("pr, qs -> pqrs", spin_p, spin_m) +
                    np.einsum("pr, qs -> pqrs", spin_z, spin_z))
    spin_2_tb_mp = system._basis_set.anti_symmetrize_u(spin_2_tb_mp)

    # S^2 = S_+ * S_- - S_z + S_z^2
    spin_2_pm = spin_p @ spin_m - spin_z + spin_z @ spin_z
    spin_2_tb_pm = (0.5 * np.einsum("pr, qs -> pqrs", spin_m, spin_p) +
                    0.5 * np.einsum("pr, qs -> pqrs", spin_p, spin_m) +
                    np.einsum("pr, qs -> pqrs", spin_z, spin_z))
    spin_2_tb_pm = system._basis_set.anti_symmetrize_u(spin_2_tb_pm)

    np.testing.assert_allclose(spin_2_mp, spin_2_pm, atol=1e-10)
    np.testing.assert_allclose(spin_2_tb_mp, spin_2_tb_pm)

    np.testing.assert_allclose(spin_2_mp, system.spin_2, atol=1e-10)
    np.testing.assert_allclose(spin_2_tb_mp, system.spin_2_tb)

    np.testing.assert_allclose(spin_2_pm, system.spin_2, atol=1e-10)
    np.testing.assert_allclose(spin_2_tb_pm, system.spin_2_tb)