from pyqcs import X, Z, H, R, CX, State, list_to_circuit def T_interaction(a, b, t): theta = -t/2 return (CX(a, b) | R(a, -theta) | X(a) | R(a, theta) | X(a) | CX(a, b)) def T_field(a, t, g): theta = g*t/2 return (H(a) | R(a, -2*theta) | H(a) | R(a, theta) | X(a) | R(a, theta) | X(a)) def T_time_slice(qbits, t, g, N): interactions_half = list_to_circuit( [T_interaction(i, i+1, t/(2*N)) for i,_ in enumerate(qbits[:-1])] ) field = list_to_circuit([T_field(i, t/N, g) for i,_ in enumerate(qbits)]) return (interactions_half | field | interactions_half)