diff --git a/src/openfermion/circuits/trotter_exp_to_qgates.py b/src/openfermion/circuits/trotter_exp_to_qgates.py index 18f4c5675..8df323ca5 100644 --- a/src/openfermion/circuits/trotter_exp_to_qgates.py +++ b/src/openfermion/circuits/trotter_exp_to_qgates.py @@ -255,7 +255,9 @@ def pauli_exp_to_qasm(qubit_operator_list, evolution_time=1.0, qubit_list=None, ] else: if len(qids) > 0: - ret_list = ret_list + ["Rz {} {}".format(term_coeff * evolution_time, qids[-1])] + ret_list = ret_list + [ + "Rz {} {}".format(2 * term_coeff * evolution_time, qids[-1]) + ] # 4. Second set of CNOTs ret_list = ret_list + cnots2 diff --git a/src/openfermion/circuits/trotter_exp_to_qgates_test.py b/src/openfermion/circuits/trotter_exp_to_qgates_test.py index 4bac8c89d..d6a970a6e 100644 --- a/src/openfermion/circuits/trotter_exp_to_qgates_test.py +++ b/src/openfermion/circuits/trotter_exp_to_qgates_test.py @@ -210,11 +210,16 @@ def test_qasm_string_Z(self): # Correct string strcorrect = '''5 CNOT 3 4 -Rz 0.6 4 +Rz 1.2 4 CNOT 3 4''' self.assertEqual(qasmstr, strcorrect) + def test_pauli_exp_to_qasm_uses_rz_angle_for_exp_minus_i_theta_z(self): + qasmstr = "\n".join(pauli_exp_to_qasm([QubitOperator('Z0', 0.5)], evolution_time=3)) + + self.assertEqual(qasmstr, 'Rz 3.0 0') + def test_qasm_string_XYZ(self): # Testing for correct QASM string output w/ Pauli-{X,Y,Z} # QubitOperator('X0 Z1 Y3', 0.5) @@ -231,7 +236,7 @@ def test_qasm_string_XYZ(self): Rx 1.5707963267948966 3 CNOT 0 1 CNOT 1 3 -Rz 0.5 3 +Rz 1.0 3 CNOT 1 3 CNOT 0 1 H 0 @@ -329,13 +334,13 @@ def test_qasm_string_multiple_operator(self): # the order in which the operators loop. strcorrect1 = '''5 CNOT 3 4 -Rz 0.6 4 +Rz 1.2 4 CNOT 3 4 H 0 Rx 1.5707963267948966 3 CNOT 0 1 CNOT 1 3 -Rz 0.5 3 +Rz 1.0 3 CNOT 1 3 CNOT 0 1 H 0 @@ -346,13 +351,13 @@ def test_qasm_string_multiple_operator(self): Rx 1.5707963267948966 3 CNOT 0 1 CNOT 1 3 -Rz 0.5 3 +Rz 1.0 3 CNOT 1 3 CNOT 0 1 H 0 Rx -1.5707963267948966 3 CNOT 3 4 -Rz 0.6 4 +Rz 1.2 4 CNOT 3 4''' try: self.assertEqual(qasmstr, strcorrect1)