Exemple #1
0
def test_predefined_common_attributes():
    """Test that expected exceptions are raised correctly for invalid parameters
    """
    # Test negative maximum Rabi rate
    with pytest.raises(ArgumentsValueError):
        _ = new_predefined_driven_control(
            maximum_rabi_rate=-1, shape='PRIMITIVE', rabi_rotation=1, azimuthal_angle=0)
    # Test zero Rabi rotation
    with pytest.raises(ArgumentsValueError):
        _ = new_predefined_driven_control(
            maximum_rabi_rate=1, shape='PRIMITIVE', rabi_rotation=0, azimuthal_angle=0)
Exemple #2
0
def test_new_predefined_driven_control():
    """Test the new_predefined_driven_control function in
       qctrlopencontrols.driven_controls.predefined
    """
    # Test that an error is raised if supplied with an unknown scheme
    with pytest.raises(ArgumentsValueError):
        _ = new_predefined_driven_control(scheme='nil')
Exemple #3
0
def test_corpse_control():
    """Test the segments of the CORPSE driven control
    """
    _rabi_rotation = np.pi
    _azimuthal_angle = np.pi/4

    k = np.arcsin(np.sin(_rabi_rotation / 2.) / 2.)

    _segments = [
        [np.cos(_azimuthal_angle), np.sin(_azimuthal_angle), 0.,
         2. * np.pi + _rabi_rotation / 2. - k],
        [np.cos(np.pi + _azimuthal_angle), np.sin(np.pi + _azimuthal_angle), 0.,
         2. * np.pi - 2. * k],
        [np.cos(_azimuthal_angle), np.sin(_azimuthal_angle), 0., _rabi_rotation / 2. - k]
    ]

    corpse_control_1 = new_compensating_for_off_resonance_with_a_pulse_sequence_control(
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=1
    )

    corpse_control_2 = new_predefined_driven_control(
        scheme=CORPSE,
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=1
    )

    for control in [corpse_control_1, corpse_control_2]:
        segments = np.vstack((
            control.amplitude_x, control.amplitude_y, control.detunings, control.durations
        )).T
        assert np.allclose(segments, _segments)
Exemple #4
0
def test_solovay_kitaev_1_control():
    """Test the segments of the Solovay-Kitaev 1 (SK1) driven control
    """
    _rabi_rotation = np.pi
    _azimuthal_angle = np.pi/2

    phi_p = np.arccos(-_rabi_rotation / (4 * np.pi))

    _segments = [
        [np.cos(_azimuthal_angle),
         np.sin(_azimuthal_angle)],
        [np.cos(-phi_p + _azimuthal_angle),
         np.sin(-phi_p + _azimuthal_angle)],
        [np.cos(phi_p + _azimuthal_angle),
         np.sin(phi_p + _azimuthal_angle)]
    ]

    sk1_control_1 = new_solovay_kitaev_1_control(
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=1
    )

    sk1_control_2 = new_predefined_driven_control(
        scheme=SK1,
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=1
    )

    durations = [np.pi, 2 * np.pi, 2 * np.pi]

    for control in [sk1_control_1, sk1_control_2]:
        segments = np.vstack((
            control.amplitude_x, control.amplitude_y
        )).T
        assert np.allclose(segments, _segments)
        assert np.allclose(control.durations, durations)
        assert np.allclose(control.detunings, 0)
Exemple #5
0
def test_wimperis_1_control():
    """Test the segments of the Wimperis 1 (BB1) driven control
    """
    _rabi_rotation = np.pi
    _azimuthal_angle = np.pi/2
    _maximum_rabi_rate = 1

    phi_p = np.arccos(-_rabi_rotation / (4 * np.pi))

    _segments = np.array([
        [np.cos(_azimuthal_angle), np.sin(_azimuthal_angle)],
        [np.cos(phi_p + _azimuthal_angle), np.sin(phi_p + _azimuthal_angle)],
        [np.cos(3. * phi_p + _azimuthal_angle), np.sin(3. * phi_p + _azimuthal_angle)],
        [np.cos(phi_p + _azimuthal_angle), np.sin(phi_p + _azimuthal_angle)]
    ])

    wimperis_control_1 = new_wimperis_1_control(
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=_maximum_rabi_rate
    )
    wimperis_control_2 = new_predefined_driven_control(
        rabi_rotation=_rabi_rotation,
        azimuthal_angle=_azimuthal_angle,
        maximum_rabi_rate=_maximum_rabi_rate,
        scheme=BB1
    )

    durations = [np.pi, np.pi, np.pi * 2, np.pi]

    for control in [wimperis_control_1, wimperis_control_2]:
        segments = np.vstack((
            control.amplitude_x, control.amplitude_y
        )).T
        assert np.allclose(segments, _segments)
        assert np.allclose(control.durations, durations)
        assert np.allclose(control.detunings, 0)
Exemple #6
0
def test_primitive_control_segments():
    """Test the segments of the predefined primitive driven control
    """
    _rabi_rate = 1
    _rabi_rotation = 1.5
    _azimuthal_angle = np.pi/2
    _segments = [
        np.cos(_azimuthal_angle),
        np.sin(_azimuthal_angle),
        0.,
        _rabi_rotation
    ]

    primitive_control_1 = new_primitive_control(
        rabi_rotation=_rabi_rotation,
        maximum_rabi_rate=_rabi_rate,
        azimuthal_angle=_azimuthal_angle
    )

    # Test the new_predefined_driven_control function also
    primitive_control_2 = new_predefined_driven_control(
        rabi_rotation=_rabi_rotation,
        maximum_rabi_rate=_rabi_rate,
        azimuthal_angle=_azimuthal_angle,
        scheme=PRIMITIVE
    )

    for control in [primitive_control_1, primitive_control_2]:
        segments = [
            control.amplitude_x[0],
            control.amplitude_y[0],
            control.detunings[0],
            control.durations[0]
        ]
        assert np.allclose(_segments, segments)
        assert np.allclose(_rabi_rate, control.maximum_rabi_rate)