def test_prefactor_vacuum(): """test the correct prefactor of 0.5 is calculated for a vacuum state""" Q = np.identity(2) beta = np.zeros([2]) res = prefactor(Means(beta), Covmat(Q)) ex = 1 assert np.allclose(res, ex)
def test_prefactor_TMS(): """test the correct prefactor of 0.5 is calculated for a TMS state""" q = np.fliplr(np.diag([2.0] * 4)) np.fill_diagonal(q, np.sqrt(2)) Q = np.fliplr(q) beta = np.zeros([4]) res = prefactor(Means(beta), Covmat(Q)) ex = 0.5 assert np.allclose(res, ex)
def test_prefactor_with_displacement(): """test the correct prefactor of 0.5 is calculated for a TMS state""" q = np.fliplr(np.diag([2.0] * 4)) np.fill_diagonal(q, np.sqrt(2)) Q = np.fliplr(q) Qinv = np.linalg.inv(Q) vect = 1.2 * np.ones([2]) + 1j * np.ones(2) beta = np.concatenate([vect, vect.conj()]) res = prefactor(Means(beta), Covmat(Q), hbar=2) ex = np.exp(-0.5 * beta @ Qinv @ beta.conj()) / np.sqrt(np.linalg.det(Q)) assert np.allclose(res, ex)