def test_two_mode_squeezing(self, tol): """Test the two mode squeezing symplectic transform.""" r = 0.543 phi = 0.123 S = two_mode_squeezing(r, phi) # test that S = B^\dagger(pi/4, 0) [S(z) x S(-z)] B(pi/4) B = beamsplitter(np.pi / 4, 0) Sz = block_diag(squeezing(r, phi), squeezing(-r, phi))[:, [0, 2, 1, 3]][[0, 2, 1, 3]] expected = B.conj().T @ Sz @ B assert S == pytest.approx(expected, abs=tol) # test that S |a1, a2> = |ta1+ra2, ta2+ra1> a1 = 0.23 + 0.12j a2 = 0.23 + 0.12j out = S @ np.array([a1.real, a2.real, a1.imag, a2.imag]) * np.sqrt( 2 * hbar) T = np.cosh(r) R = np.exp(1j * phi) * np.sinh(r) a1out = T * a1 + R * np.conj(a2) a2out = T * a2 + R * np.conj(a1) expected = np.array([a1out.real, a2out.real, a1out.imag, a2out.imag ]) * np.sqrt(2 * hbar) assert out == pytest.approx(expected, abs=tol)
def test_two_mode_squeezing(self): """Test the two mode squeezing symplectic transform.""" self.logTestName() r = 0.543 phi = 0.123 S = two_mode_squeezing(r, phi) # test that S = B^\dagger(pi/4, 0) [S(z) x S(-z)] B(pi/4) B = beamsplitter(np.pi / 4, 0) Sz = block_diag(squeezing(r, phi), squeezing(-r, phi))[:, [0, 2, 1, 3]][[0, 2, 1, 3]] expected = B.conj().T @ Sz @ B self.assertAllAlmostEqual(S, expected, delta=self.tol) # test that S |a1, a2> = |ta1+ra2, ta2+ra1> a1 = 0.23 + 0.12j a2 = 0.23 + 0.12j out = S @ np.array([a1.real, a2.real, a1.imag, a2.imag]) * np.sqrt( 2 * hbar) T = np.cosh(r) R = np.exp(1j * phi) * np.sinh(r) a1out = T * a1 + R * np.conj(a2) a2out = T * a2 + R * np.conj(a1) expected = np.array([a1out.real, a2out.real, a1out.imag, a2out.imag ]) * np.sqrt(2 * hbar) self.assertAllAlmostEqual(out, expected, delta=self.tol)