def test_anti_symmetric_properties(): l_half = 10 u = np.random.random((l_half, l_half, l_half, l_half)) # Make u symmetric u = u + u.transpose(1, 0, 3, 2) u = BasisSet.anti_symmetrize_u(BasisSet.add_spin_two_body(u, np=np)) np.testing.assert_allclose(u, -u.transpose(0, 1, 3, 2), atol=1e-10) np.testing.assert_allclose(u, -u.transpose(1, 0, 2, 3), atol=1e-10) np.testing.assert_allclose(u, u.transpose(1, 0, 3, 2), atol=1e-10)
def test_spin_two_body(): l_half = 10 u = np.random.random((l_half, l_half, l_half, l_half)) l = l_half * 2 u_spin = np.zeros((l, l, l, l)) for p in range(l): for q in range(l): for r in range(l): for s in range(l): u_spin[p, q, r, s] = (spin_delta(p, r) * spin_delta(q, s) * u[p // 2, q // 2, r // 2, s // 2]) np.testing.assert_allclose(u_spin, BasisSet.add_spin_two_body(u, np=np), atol=1e-10)
def test_anti_symmetrize_u(): l_half = 10 u = np.random.random((l_half, l_half, l_half, l_half)) # Make u symmetric u = u + u.transpose(1, 0, 3, 2) l = l_half * 2 u_spin = np.zeros((l, l, l, l)) for p in range(l): for q in range(l): for r in range(l): for s in range(l): u_spin[p, q, r, s] = (spin_delta(p, r) * spin_delta(q, s) * u[p // 2, q // 2, r // 2, s // 2]) u_spin[p, q, r, s] -= (spin_delta(p, s) * spin_delta(q, r) * u[p // 2, q // 2, s // 2, r // 2]) np.testing.assert_allclose( u_spin, BasisSet.anti_symmetrize_u(BasisSet.add_spin_two_body(u, np=np)), atol=1e-10, )
def test_antisymmetric_two_body_elements(u): l = len(u) _u = BasisSet.anti_symmetrize_u( BasisSet.add_spin_two_body(get_coulomb_elements(l // 2), np=np)) np.testing.assert_allclose(u, _u, atol=1e-6, rtol=1e-6)