diff --git a/qctrlopencontrols/qiskit/__init__.py b/qctrlopencontrols/qiskit/__init__.py index 062224f0..5c968758 100644 --- a/qctrlopencontrols/qiskit/__init__.py +++ b/qctrlopencontrols/qiskit/__init__.py @@ -18,5 +18,6 @@ ============= """ -from .constants import (FIX_DURATION_UNITARY, INSTANT_UNITARY) +from .constants import (FIX_DURATION_UNITARY, INSTANT_UNITARY, + DEFAULT_PRE_POST_GATE_PARAMETERS) from .quantum_circuit import convert_dds_to_quantum_circuit diff --git a/qctrlopencontrols/qiskit/constants.py b/qctrlopencontrols/qiskit/constants.py index ee1cb269..91618fcd 100644 --- a/qctrlopencontrols/qiskit/constants.py +++ b/qctrlopencontrols/qiskit/constants.py @@ -18,6 +18,8 @@ ================ """ +import numpy as np + FIX_DURATION_UNITARY = 'fixed duration unitary' """Algorithm to convert a DDS to Quantum circuit where the unitaries are considered as gates with finite duration @@ -27,3 +29,7 @@ """Algorithm to convert a DDS to Quantum circuit where the unitaties are considered as instantaneous operation. """ + +DEFAULT_PRE_POST_GATE_PARAMETERS = (np.pi / 2, -np.pi / 2, np.pi / 2) +"""Parameters of a default U3 gate for pre-post rotation for circuits. +""" diff --git a/qctrlopencontrols/qiskit/quantum_circuit.py b/qctrlopencontrols/qiskit/quantum_circuit.py index 548b12c1..0b0c6e32 100644 --- a/qctrlopencontrols/qiskit/quantum_circuit.py +++ b/qctrlopencontrols/qiskit/quantum_circuit.py @@ -27,7 +27,8 @@ from qctrlopencontrols.dynamic_decoupling_sequences import DynamicDecouplingSequence from qctrlopencontrols.exceptions import ArgumentsValueError -from .constants import (FIX_DURATION_UNITARY, INSTANT_UNITARY) +from .constants import (FIX_DURATION_UNITARY, INSTANT_UNITARY, + DEFAULT_PRE_POST_GATE_PARAMETERS) def _get_circuit_gate_list(dynamic_decoupling_sequence, @@ -131,7 +132,7 @@ def convert_dds_to_quantum_circuit( dynamic_decoupling_sequence, target_qubits=None, gate_time=0.1, - pre_post_gate_parameters=None, + pre_post_gate_parameters=DEFAULT_PRE_POST_GATE_PARAMETERS, add_measurement=True, algorithm=FIX_DURATION_UNITARY, quantum_registers=None, @@ -148,13 +149,14 @@ def convert_dds_to_quantum_circuit( defaults to None gate_time : float, optional Time (in seconds) delay introduced by a gate; defaults to 0.1 - pre_post_gate_parameters : list, optional - List of (length 3) floating point numbers; These numbers correspond to :math:`\\theta, - \\phi, \\lambda` parameters in `U3` gate defined in Qiskit as `U3Gate(theta, phi, lamda)`. - Qiskit documentation suggests this to be the most generalized definition of unitary - gates. Defaults to None; if None, the parameters are assumed to be - :math:`[pi/2, -pi/2, pi/2]` that corresponds to `pi/2` rotation around X-axis. - See `IBM-Q Documentation + pre_post_gate_parameters : tuple or None, optional + Tuple of (length 3) floating point numbers that correspond to :math:`\\theta, + \\phi, \\lambda` parameters respectively in `U3` gate defined in Qiskit + as `U3Gate(theta, phi, lambda)`. Qiskit documentation suggests this to be + the most generalized definition of unitary gates. Defaults to + (pi/2, -pi/2, pi/2) that corresponds to a :math:`pi/2` + rotation around X-axis; if None, the resulting circuit will have no `pre` or `post` + gates. See `IBM-Q Documentation