qctrlopencontrols package¶
Subpackages¶
- qctrlopencontrols.base package
- qctrlopencontrols.driven_controls package
- qctrlopencontrols.dynamic_decoupling_sequences package
- qctrlopencontrols.exceptions package
- qctrlopencontrols.globals package
Module contents¶
qctrlopencontrols¶
-
qctrlopencontrols.convert_dds_to_driven_control(dynamic_decoupling_sequence=None, maximum_rabi_rate=6.283185307179586, maximum_detuning_rate=6.283185307179586, **kwargs)¶ Creates a Driven Control based on the supplied DDS and other relevant information
Parameters: - dynamic_decoupling_sequence (qctrlopencontrols.DynamicDecouplingSequence) – The base DDS; Defaults to None
- maximum_rabi_rate (float, optional) – Maximum Rabi Rate; Defaults to 1.0
- maximum_detuning_rate (float, optional) – Maximum Detuning Rate; Defaults to None
- kwargs (dict, optional) – options to make the corresponding filter type. I.e. the options for primitive is described in doc for the PrimitivePulse class.
Returns: The Driven Control that contains the segments corresponding to the Dynamic Decoupling Sequence operation
Return type: DrivenControls
Raises: ArgumentsValueError– Raised when an argument is invalid or a valid driven control cannot be created from the sequence parameters, maximum rabi rate and maximum detuning rate providedNotes
Driven pulse is defined as a sequence of control segments. Each segment performs an operation (rotation around one or more axes). While the dynamic decoupling sequence operation contains ideal instant operations, maximum rabi (detuning) rate defines a minimum time required to perform a given rotation operation. Therefore, each operation in sequence is converted to a flat-topped control segment with a finite duration. Each offset is taken as the mid-point of the control segment and the width of the segment is determined by (rotation/max_rabi(detuning)_rate).
If the sequence contains operations at either of the extreme ends \(\tau_0=0\) and \(\tau_{n+1}=\tau\) or finishing after the sequence duration \(t>\tau\). In these cases, the segments on either of the extreme ends are shifted appropriately so that their start/end time falls entirely within the duration of the sequence.
Moreover, a check is made to make sure the resulting control segments are non-overlapping.
If appropriate control segments cannot be created, the conversion process raises an ArgumentsValueError.
-
qctrlopencontrols.new_predefined_dds(scheme='spin echo', **kwargs)¶ Create a new instance of ne of the predefined dynamic decoupling sequence
Parameters: - scheme (string) – The name of the sequence; Defaults to ‘Spin echo’ Available options are, - ‘Ramsey’ - ‘Spin echo’, - ‘Carr-Purcell’, - ‘Carr-Purcell-Meiboom-Gill’, - ‘Uhrig single-axis’ - ‘Periodic single-axis’ - ‘Walsh single-axis’ - ‘Quadratic’ - ‘X concatenated’ - ‘XY concatenated’
- kwargs (dict, optional) – Additional keyword argument to create the sequence
Returns: Returns a sequence corresponding to the name
Return type: qctrlopencontrols.dynamic_decoupling_sequences.DynamicDecouplingSequence
Raises: ArgumentsValueError– Raised when an argument is invalid.
-
qctrlopencontrols.new_predefined_driven_control(scheme='primitive', **kwargs)¶ Create a new driven control
Parameters: - scheme (string, optional) – Defaults to None. The name of the driven control type, supported options are: - ‘primitive’ - ‘wimperis_1’ - ‘solovay_kitaev_1’ - ‘compensating_for_off_resonance_with_a_pulse_sequence’ - ‘compensating_for_off_resonance_with_a_pulse_sequence_with_wimperis’ - ‘compensating_for_off_resonance_with_a_pulse_sequence_with_solovay_kitaev’ - ‘walsh_amplitude_modulated_filter_1’ - ‘short_composite_rotation_for_undoing_length_over_and_under_shoot’ - ‘corpse_in_scrofulous’
- kwargs (dict, optional) – options to make the corresponding control type.
Returns: Returns a driven control corresponding to the driven_control_type.
Return type: qctrlopencontrols.DrivenControls
Raises: ArgumentsValueError– Raised when an argument is invalid.
-
class
qctrlopencontrols.DrivenControl(rabi_rates=None, azimuthal_angles=None, detunings=None, durations=None, name=None)¶ Bases:
objectCreates a driven control. A driven is a set of segments made up of amplitude vectors and corresponding durations.
Parameters: - rabi_rates (numpy.ndarray, optional) – 1-D array of size nx1 where n is number of segments; Each entry is the rabi rate for the segment. Defaults to None
- azimuthal_angles (numpy.ndarray, optional) – 1-D array of size nx1 where n is the number of segments; Each entry is the azimuthal angle for the segment; Defaults to None
- detunings (numpy.ndarray, optional) – 1-D array of size nx1 where n is the number of segments; Each entry is the detuning angle for the segment; Defaults to None
- durations (numpy.ndarray, optional) – 1-D array of size nx1 where n is the number of segments; Each entry is the duration of the segment (in seconds); Defaults to None
- name (string, optional) – An optional string to name the driven control. Defaults to None.
Raises: ArgumentsValueError– Raised when an argument is invalid.-
amplitude_x¶ Return the X-Amplitude
Returns: X-Amplitude of each segment Return type: numpy.ndarray
-
amplitude_y¶ Return the Y-Amplitude
Returns: Y-Amplitude of each segment Return type: numpy.ndarray
-
angles¶ Returns the angles
Returns: Angles as 1-D array of floats Return type: numpy.darray
-
directions¶ Returns the directions
Returns: Directions as 1-D array of floats Return type: numpy.ndarray
-
duration¶ Returns the total duration of the control
Returns: Total duration of the control Return type: float
-
export(coordinates='cylindrical', dimensionless_rabi_rate=True)¶ Returns a dictionary formatted for plotting using the qctrl-visualizer package.
Parameters: - dimensionless_rabi_rate (boolean) – If True, normalizes the Rabi rate so that its largest absolute value is 1.
- coordinates (string) – Indicates whether the Rabi frequency should be plotted in terms of its ‘cylindrical’ or ‘cartesian’ components.
Returns: Dictionary with plot data that can be used by the plot_controls method of the qctrl-visualizer package. It has keywords ‘Rabi rate’ and ‘Detuning’ for ‘cylindrical’ coordinates and ‘X amplitude’, ‘Y amplitude’, and ‘Detuning’ for ‘cartesian’ coordinates.
Return type: dict
Raises: ArgumentsValueError– Raised when an argument is invalid.
-
export_to_file(filename=None, file_format='Q-CTRL expanded', file_type='CSV', coordinates='cylindrical')¶ Prepares and saves the driven control in a file.
Parameters: - filename (str, optional) – Name and path of the file to save the control into. Defaults to None
- file_format (str) – Specified file format for saving the control. Defaults to ‘Q-CTRL expanded’; Currently it does not support any other format. For detail of the Q-CTRL Expanded Format consult Q-CTRL Control Data Format <https://docs.q-ctrl.com/output-data-formats#q-ctrl-hardware> _.
- file_type (str, optional) – One of ‘CSV’ or ‘JSON’; defaults to ‘CSV’.
- coordinates (str, optional) – Indicates the co-ordinate system requested. Must be one of ‘Cylindrical’, ‘Cartesian’; defaults to ‘Cylindrical’
References
Q-CTRL Control Data Format <https://docs.q-ctrl.com/output-data-formats#q-ctrl-hardware> _.
Raises: ArgumentsValueError– Raised if some of the parameters are invalid.
-
maximum_detuning¶ Returns the maximum detuning of the control
Returns: The maximum detuning of the control Return type: float
-
maximum_duration¶ Returns the maximum duration of all the control segments
Returns: The maximum duration of all the control segments Return type: float
-
maximum_rabi_rate¶ Returns the maximum rabi rate of the control
Returns: The maximum rabi rate of the control Return type: float
-
minimum_duration¶ Returns the minimum duration of all the control segments
Returns: The minimum duration of all the controls segments Return type: float
-
number_of_segments¶ Returns the number of segments
Returns: The number of segments in the driven control Return type: int
-
times¶ Returns the time of each segment within the duration of the control
Returns: Segment times as 1-D array of floats Return type: numpy.ndarray
-
class
qctrlopencontrols.DynamicDecouplingSequence(duration=1.0, offsets=None, rabi_rotations=None, azimuthal_angles=None, detuning_rotations=None, name=None)¶ Bases:
objectCreate a dynamic decoupling sequence. Can be made of perfect operations, or realistic pulses.
Parameters: - duration (float) – Defaults to 1. The total time in seconds for the sequence.
- offsets (list) – Defaults to None. The times offsets in s for the center of pulses. If None, defaults to one operation at halfway [0.5].
- rabi_rotations (list) – Default to None. The rabi rotations at each time offset. If None, defaults to np.pi at each time offset.
- azimuthal_angles (list) – Default to None. The azimuthal angles at each time offset. If None, defaults to 0 at each time offset.
- detuning_rotations (list) – Default to None. The detuning rotations at each time offset. If None, defaults to 0 at each time offset.
- name (str) – Name of the sequence; Defaults to None
Raises: qctrlopencontrols.exceptions.ArgumentsValueError– is raised if one of the inputs is invalid.-
export()¶ Returns a dictionary formatted for plotting using the qctrl-visualizer package.
Returns: Dictionary with plot data that can be used by the plot_sequences method of the qctrl-visualizer package. It has keywords ‘Rabi’ and ‘Detuning’. Return type: dict
-
export_to_file(filename=None, file_format='Q-CTRL expanded', file_type='CSV', coordinates='cylindrical', maximum_rabi_rate=6.283185307179586, maximum_detuning_rate=6.283185307179586)¶ Prepares and saves the dynamic decoupling sequence in a file.
Parameters: - filename (str, optional) – Name and path of the file to save the control into. Defaults to None
- file_format (str) – Specified file format for saving the control. Defaults to ‘Q-CTRL expanded’; Currently it does not support any other format. For detail of the Q-CTRL Expanded Format consult Q-CTRL Control Data Format <https://docs.q-ctrl.com/output-data-formats#q-ctrl-hardware> _.
- file_type (str, optional) – One of ‘CSV’ or ‘JSON’; defaults to ‘CSV’.
- coordinates (str, optional) – Indicates the co-ordinate system requested. Must be one of ‘Cylindrical’, ‘Cartesian’; defaults to ‘Cylindrical’
- maximum_rabi_rate (float, optional) – Maximum Rabi Rate; Defaults to \(2\pi\)
- maximum_detuning_rate (float, optional) – Maximum Detuning Rate; Defaults to \(2\pi\)
References
Q-CTRL Control Data Format <https://docs.q-ctrl.com/output-data-formats#q-ctrl-hardware> _.
Raises: ArgumentsValueError– Raised if some of the parameters are invalid.Notes
The sequence is converted to a driven control using the maximum rabi and detuning rate. The driven control is then exported. This is done to facilitate a coherent integration with Q-CTRL BLACK OPAL’s 1-Qubit workspace.
-
number_of_offsets¶ Returns the number of offsets
Returns: The number of offsets in the dynamic decoupling sequence Return type: int