Ejemplo n.º 1
0
def test_if_quadratic_sequence_with_even_inner_pulses_is_identity():
    """
    Tests if the product of the pulses in a quadratic sequence with pre/post
    pi/2-pulses is an identity, when the total number of inner pulses is even.
    """
    inner_even_quadratic_sequence = new_quadratic_sequence(
        duration=10.0,
        inner_offset_count=8,
        outer_offset_count=7,
        pre_post_rotation=True,
    )

    # n_outer + n_inner*(n_outer+1) pi-pulses + 2 pi/2-pulses
    # total number here is even
    assert len(inner_even_quadratic_sequence.offsets) == 7 + 8 * (7 + 1) + 2

    assert _pulses_produce_identity(inner_even_quadratic_sequence)
Ejemplo n.º 2
0
def test_quadratic_sequence():
    """
    Tests the quadratic sequence.
    """

    duration = 10.0
    inner_offset_count = 4
    outer_offset_count = 4

    sequence = new_quadratic_sequence(
        duration=duration,
        inner_offset_count=inner_offset_count,
        outer_offset_count=outer_offset_count,
    )

    _offsets = np.zeros((outer_offset_count + 1, inner_offset_count + 1))

    constant = 0.5 / (outer_offset_count + 1)
    _delta_positions = [
        duration * (np.sin(np.pi * (k + 1) * constant))**2
        for k in range(outer_offset_count)
    ]

    _outer_offsets = np.array(_delta_positions)
    _offsets[0:outer_offset_count, -1] = _outer_offsets

    _outer_offsets = np.insert(
        _outer_offsets,
        [0, _outer_offsets.shape[0]],
        [0, duration],
    )
    _inner_durations = _outer_offsets[1:] - _outer_offsets[0:-1]

    constant = 0.5 / (inner_offset_count + 1)
    _delta_positions = [(np.sin(np.pi * (k + 1) * constant))**2
                        for k in range(inner_offset_count)]
    _delta_positions = np.array(_delta_positions)
    for inner_sequence_idx in range(_inner_durations.shape[0]):
        _inner_deltas = _inner_durations[inner_sequence_idx] * _delta_positions
        _inner_deltas = _outer_offsets[inner_sequence_idx] + _inner_deltas
        _offsets[inner_sequence_idx, 0:inner_offset_count] = _inner_deltas

    _rabi_rotations = np.zeros(_offsets.shape)
    _detuning_rotations = np.zeros(_offsets.shape)

    _rabi_rotations[0:outer_offset_count, -1] = np.pi
    _detuning_rotations[0:(outer_offset_count + 1),
                        0:inner_offset_count] = np.pi

    _offsets = np.reshape(_offsets, (-1, ))
    _rabi_rotations = np.reshape(_rabi_rotations, (-1, ))
    _detuning_rotations = np.reshape(_detuning_rotations, (-1, ))

    _offsets = _offsets[0:-1]
    _rabi_rotations = _rabi_rotations[0:-1]
    _detuning_rotations = _detuning_rotations[0:-1]

    _azimuthal_angles = np.zeros(_offsets.shape)

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_quadratic_sequence(
        duration=duration,
        inner_offset_count=inner_offset_count,
        outer_offset_count=outer_offset_count,
        pre_post_rotation=True,
    )

    _offsets = np.insert(_offsets, [0, _offsets.shape[0]], [0, duration])
    _rabi_rotations = np.insert(_rabi_rotations, [0, _rabi_rotations.shape[0]],
                                [np.pi / 2, np.pi / 2])
    _detuning_rotations = np.insert(_detuning_rotations,
                                    [0, _detuning_rotations.shape[0]], [0, 0])

    _azimuthal_angles = np.zeros(_offsets.shape)
    _azimuthal_angles[-1] = np.pi

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)